8

I've a LEMP environment and need the option to separate all development subdomains from staging (development with xdebug staging without).

  • dev.projectX.mydomain.tld
  • staging.projectX.mydomain.tld

Therefore I set up two pools php-dev and php-stage, but it seems that i can enable extensions only in the php.ini!?

Here is my pool.conf (dev)

[php-dev]
listen = 127.0.0.1:9101
listen = /var/run/php-fpm/a1-php-dev.socket
listen.backlog = -1
listen.allowed_clients = 127.0.0.1

user = nginx
group = nginx

request_slowlog_timeout = 3s
slowlog = /var/log/php-fpm/slowlog-php-dev.log

pm = dynamic
pm.max_children = 20
pm.start_servers = 10
pm.min_spare_servers = 4
pm.max_spare_servers = 16
pm.max_requests = 500
pm.status_path = /status

request_terminate_timeout = 120s
rlimit_files = 131072
rlimit_core = unlimited
catch_workers_output = yes

env[HOSTNAME] = $HOSTNAME
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

php_admin_value[zend_extension]         = "/usr/lib64/php/modules/xdebug.so"
php_admin_value[xdebug.default_enable]      = 0
php_admin_value[xdebug.remote_enable]       = 0
php_admin_value[xdebug.remote_autostart]        = 0
php_admin_value[xdebug.remote_host]         = localhost 
php_admin_value[xdebug.profiler_enable_trigger]     = 0
php_admin_value[xdebug.remote_port]         = 9001
php_admin_value[xdebug.collect_params]      = 2
php_admin_value[xdebug.collect_vars]        = 1
php_admin_value[xdebug.trace_format]        = 2

Unfortunately, xdebug won't be loaded.

Is there any other option to load xdebug only on dev.* domains?

4 Answers4

6

Unfortunately you can't load different modules or version of modules for each FPM pool. So far I've created multiple completely separate instances of PHP-FPM in similar situations.

replay
  • 3,180
  • 13
  • 16
1

Yes, but the extra pool also needs to run under a separate service. That service can use the same binaries, but needs its own conf files and (some) dirs. How to achieve this depends on your system and its service manager. I used this answer as a basis because I have systemd.

Walf
  • 293
  • 1
  • 3
  • 16
0

XDebug in combination with PHP-FPM has one pitfall - option xdebug.mode can be set only in php.ini. But if you have one production and one staging site using the same php.ini and you want xdebug enabled for staging but disabled for production (cos of performance) you got a problem. You can solve that by creating another php-fpm service (https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files) and in unit configuration you can set php.ini file which will be new ini file with xdebug enabled. Then you just need to make sure that your debug requests point to this new php-fpm (which you can do by setting fpm pool's listening host and port).

Hope I left some clues for others struggling with xdebug, php-fpm and php.ini stuff...

Ales
  • 101
  • 2
0

simplest is to create service in /etc/init/php-xdebug

start on runlevel [2345]
stop on runlevel [016]

# you can uncomment this with recent upstart
# reload signal USR2

pre-start script
mkdir -p /run/php
chmod 0755 /run/php
chown www-data:www-data /run/php
end script

respawn
exec /usr/sbin/php-fpm7.0 --nodaemonize --fpm-config /etc/php/7.0/fpm/php-xdebug.conf
James M
  • 200
  • 1
  • 2
  • 12