Last active
May 12, 2017 02:54
-
-
Save jpcaparas/a0764f204385de5aec27b8ca27d59e9b to your computer and use it in GitHub Desktop.
Enabling PHP 7.0 Xdebug on a Vagrant Debian 8 image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### IMPORTANT: Run this command as sudo ### | |
### Sample steps ### | |
# 1. `vagrant ssh` into your machine | |
# 2. Run `curl http://[raw-url-to-this-script.sh] | sudo sh | |
### VARS (Change values as needed) ### | |
XDEBUG_IS_INSTALLED_PATTERN="xdebug.remote_enable=1" | |
XDEBUG_INI_PATH="/etc/php/7.0/mods-available/xdebug.ini" | |
XDEBUG_REMOTE_ENABLE="yes" # Xdebug should try to contact a debug client which is listening on the host | |
XDEBUG_REMOTE_CONNECT_BACK="yes" # Xdebug will try to connect to the client that made the HTTP request | |
XDEBUG_REMOTE_PORT="9000" # The value is, by default, already 9000, but we're making it explicit | |
XDEBUG_REMOTE_HOST="10.10.10.10" # Change this to your machine IP | |
XDEBUG_IDEKEY="vagrant" # Use with the XDebug helper (Chrome extension) | |
### Install the module ### | |
apt-get install php7.0-xdebug | |
### Append configs | |
if ! grep -q $XDEBUG_IS_INSTALLED_PATTERN $XDEBUG_INI_PATH; then | |
printf "Configuring Xdebug...\n" | |
sudo printf "\ | |
xdebug.remote_enable=$XDEBUG_REMOTE_ENABLE\n\ | |
xdebug.remote_connect_back=$XDEBUG_REMOTE_CONNECT_BACK\n\ | |
xdebug.remote_host=$XDEBUG_REMOTE_HOST\n\ | |
xdebug.remote_port=$XDEBUG_REMOTE_PORT\n\ | |
xdebug.idekey=$XDEBUG_IDEKEY\n" >> $XDEBUG_INI_PATH | |
printf "Configuration done.\n" | |
else | |
printf "Xdebug is already configured.\n" | |
fi | |
### Restart PHP-FPM ### | |
systemctl restart php7.0-fpm | |
### Resources ### | |
# - PHPSTORM integration: https://www.sitepoint.com/install-xdebug-phpstorm-vagrant/ # |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instructions for using this snippet:
vagrant ssh
into your machine.install-xdebug.sh
and runsh install-xdebug.sh
Gotchas:
vagrant
for XDebug to connect back.