On this page
Setting up remote debugging
In order to run xdebug on our remote development servers, we need to do some configuration.
Debugging Web Requests:
First we need to configure .user.ini file in the htdocs directory. Apache will read this file and apply any changes it finds in there to the php invocation for web requests.
Set the remote port to the same number as your unix user id (`id -u`)
xdebug.remote_port={UNIX USERID}
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.idekey=projectdebug
xdebug.remote_log=/home/{USERNAME}/xdebug/xdebug.logDebugging Drush Commands:
In order for drush to work with xdebug, we need to make the same settings changes to your remote drush.ini file on devwww located at ~/.drush/drush.ini
xdebug.remote_port={UNIX USERID}
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.idekey=projectdebug
xdebug.remote_log=/home/{USERNAME}/xdebug/xdebug.log Drush is installed at the server via a Phar file, which is not compatible with drush.ini. Therefore, if you want to debug Drush commands you need to:
1. Find out the version of Drush that the server uses via drush --version
2. Download that version from https://github.com/drush-ops/drush/releases. Then extract it to your home path and install dependencies via composer install.
3. Run Drush like this: cd /home/my-user/drush-8.1.0/drush; ./drush --root=/path/to/htdocs command
Setup PHP server on phpstorm
Option 1: using a Server
Preferences->Languages & Frameworks -> PHP-> Servers
Add Server -> name it after your dev site
Host field is the URL of your devsite -port 80 and xdebug
Check Use path mapping (select if the server is remote or symlinks are used)
And then map your local paths to the path on the server. (the boxes on the right have the path mappings)
Option 2: setting up an SSH tunnel
An alternative method is to allow external connections at XDebug and set up an SSH tunnel. Here are the Xdebug settings at PHPStorm:
And here is how to set up the SSH tunnel:
ssh -R [your $UNIX_USERID]:localhost:9000 [your username]@devwww.drupalsystems.orgNext, set a breakpoint, and start listening connections by clicking on the green phone icon at PHP Storm. Finally, open a page in the browser that runs the code where you did set the breakpoint. It should stop there.
Setup Debug Configuration on phpstorm
Run->Edit Configurations
Add a PHP Remote Debug
Name it after your site
Select your server from the dropdown.
set the Ide key(session id) to projectdebug
Setup SSH On your local machine
Host dev-debug
HostName wwwdev1.drupalsystems.org
User {USERNAME ON DEV}
IdentityFile {PATH TO YOUR PRIVATE KEY
RemoteForward {UNIX USERID} localhost:9000
ServerAliveInterval 60
LogLevel QUIET
ExitOnForwardFailure yesSetup Drush locally by adding the following to a ~/.drush/devwww.aliases.drushrc.php file to run remote drush commands
$aliases['{YOURALIAS}'] = array(
'uri' => '{YOURSITE}.dev.devdrupal.org',
'remote-host' => 'wwwdev1.drupalsystems.org',
'root' => '/var/www/dev/{YOURSITE}.dev.devdrupal.org/htdocs',
'remote-user' => '{USERNAME ON DEV}',
'ssh-options' => '-i {LOCAL_PATH_TO_YOUR_SSH_PRIVATE_KEY} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no',
'path-aliases' => array(
'%drush-script' => '/usr/local/bin/drush',
),
);Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion