Vagrant 中的 Xdebug laravel/homestead V0.4.0 / v3.0.1
Xdebug in Vagrant laravel/homestead V0.4.0 / v3.0.1
我搭建了一个vagrant box laravel/homestead v0.4.0.
我使用 composer 安装 homestead V3.0.1。
最后我 运行 "vagrant up" 然后 "vagrant ssh" 并且我在 Homestead VM 中,但是......
它应该包括 Xdebug
,但它没有...
当我 运行 phpinfo()
时没有 Xdebug 信息。
同样在 /etc/php/7.0/fpm/php.ini
或 config.d
文件夹中,没有 Xdebug 的配置。
我的最终目标是能够使用 Netbeans IDE 调试 laravel 项目。该项目 运行ning 在 homestead VM 中,但我无法理解为什么 homestead 虚拟机中没有 Xdebug。
非常感谢任何有助于实现这一目标的帮助
编辑:从版本 0.4.1 开始,XDebug 被放回 Homestead。不再需要从源代码编译 XDebug。
在您的 ~/.homestead
目录中,应该有一个名为 after.sh
的文件。这将为您提供一种在 Homestead 配置程序完成后执行您自己的命令的方法。
将以下内容复制并粘贴到您的 after.sh
文件中:
#!/bin/sh
# Install Xdebug
git clone git://github.com/xdebug/xdebug.git
cd xdebug
phpize
./configure --enable-xdebug
make
make install
# Configure Xdebug
cat > /etc/php/mods-available/xdebug.ini <<EOL
zend_extension=xdebug.so
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
EOL
ln -s /etc/php/mods-available/xdebug.ini /etc/php/7.0/fpm/conf.d/20-xdebug.ini
service php7.0-fpm restart
一旦完成,运行一个vagrant destroy
和一个vagrant up
,或运行 vagrant provision
以确保shell命令正确执行。
此版本的 XDebug 是 Github Master 分支的直接克隆。 这个分支被认为是不稳定的。 一旦 Xdebug github 帐户为 2.4 或 2.5 添加了一个分支,确保更新你的 shell 命令以在之前检查那个分支运行设置各种配置和 make 命令。
此外,我只是将 Xdebug 添加到 FPM 配置中。 我没有将它添加到 CLI 配置中。您可能只会在 phpinfo()
调用中看到 Xdebug,而不是 php -i
调用。
除此之外,我在自己的环境中进行了测试:
- Homestead盒子版本0.4
- Github 克隆 laravel/homestead 3.0.1
- PHPStorm IDE
一切似乎都按预期进行。让我知道这是否有帮助。
这就是您在 ~/.homestead/after.sh:
中所需要的全部内容
#!/bin/sh
# If you would like to do some extra provisioning you may
# add any commands you wish to this file and they will
# be run after the Homestead machine is provisioned.
apt-get install php-xdebug
就运行这个在你的宅基地
php -v
sudo phpenmod xdebug
sudo service nginx restart
我搭建了一个vagrant box laravel/homestead v0.4.0.
我使用 composer 安装 homestead V3.0.1。
最后我 运行 "vagrant up" 然后 "vagrant ssh" 并且我在 Homestead VM 中,但是......
它应该包括 Xdebug
,但它没有...
当我 运行 phpinfo()
时没有 Xdebug 信息。
同样在 /etc/php/7.0/fpm/php.ini
或 config.d
文件夹中,没有 Xdebug 的配置。
我的最终目标是能够使用 Netbeans IDE 调试 laravel 项目。该项目 运行ning 在 homestead VM 中,但我无法理解为什么 homestead 虚拟机中没有 Xdebug。 非常感谢任何有助于实现这一目标的帮助
编辑:从版本 0.4.1 开始,XDebug 被放回 Homestead。不再需要从源代码编译 XDebug。
在您的 ~/.homestead
目录中,应该有一个名为 after.sh
的文件。这将为您提供一种在 Homestead 配置程序完成后执行您自己的命令的方法。
将以下内容复制并粘贴到您的 after.sh
文件中:
#!/bin/sh
# Install Xdebug
git clone git://github.com/xdebug/xdebug.git
cd xdebug
phpize
./configure --enable-xdebug
make
make install
# Configure Xdebug
cat > /etc/php/mods-available/xdebug.ini <<EOL
zend_extension=xdebug.so
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
EOL
ln -s /etc/php/mods-available/xdebug.ini /etc/php/7.0/fpm/conf.d/20-xdebug.ini
service php7.0-fpm restart
一旦完成,运行一个vagrant destroy
和一个vagrant up
,或运行 vagrant provision
以确保shell命令正确执行。
此版本的 XDebug 是 Github Master 分支的直接克隆。 这个分支被认为是不稳定的。 一旦 Xdebug github 帐户为 2.4 或 2.5 添加了一个分支,确保更新你的 shell 命令以在之前检查那个分支运行设置各种配置和 make 命令。
此外,我只是将 Xdebug 添加到 FPM 配置中。 我没有将它添加到 CLI 配置中。您可能只会在 phpinfo()
调用中看到 Xdebug,而不是 php -i
调用。
除此之外,我在自己的环境中进行了测试:
- Homestead盒子版本0.4
- Github 克隆 laravel/homestead 3.0.1
- PHPStorm IDE
一切似乎都按预期进行。让我知道这是否有帮助。
这就是您在 ~/.homestead/after.sh:
中所需要的全部内容#!/bin/sh
# If you would like to do some extra provisioning you may
# add any commands you wish to this file and they will
# be run after the Homestead machine is provisioned.
apt-get install php-xdebug
就运行这个在你的宅基地
php -v
sudo phpenmod xdebug
sudo service nginx restart