Some time it may require users to have modules like
xdebug on their hosted app. By default, xdebug module is not avail in the PHP app due to security & performance reasons.
To work around this you will need to build your entire web stack from source (including PHP and Nginx) and then build
xdebug against that and enable it in your own
This post deals with workaround on getting
xdebug enabled for your PHP app. Hope this may be useful for future readers (and future me as well) .
- Need to build entire web stack from source (including PHP and Nginx/Apache)
- Run a private PHP-FPM stack on Nginx or Apache
- Build xdebug against that and enable it in your own php.ini
- Validate the config
1a Building PHP
tar -xzf php-8.1.1.tar.gz
./configure --prefix=/home/kesavan/opt/ --with-pdo-mysql
make install && make
You may check the installed version by executing ~/opt/bin/php -v
0 ✓ success ^_^ ______
1b Building Apache
./configure --prefix=/home/kesavan/opt/ --enabled-shared=max --enable-module=most
make && make install
At the end, you'll likely have the following binaries:
ab apxs dbmmanage envvars-std htcacheclean htdigest httpd logresolve phar.phar php-cgi phpdbg rotatelogs
apachectl checkgid envvars fcgistarter htdbm htpasswd httxt2dbm phar php php-config phpize
PHP Api Version: 20210902
Zend Module Api No: 20210902
Zend Extension Api No: 420210902
2 Run a private PHP-FPM stack on Nginx or Apache
There's a good article on the forum on the same. HOWTO run a private PHP-FPM stack on Nginx or Apache on Opalstack - Opalstack Community Forum. Please follow the steps. Also don't forgot to link the
php-fpm to the above build
php-fpm. On completion of the set-up, you may end up with similar to :
Note back , don't link the
httpd; Let it mapped with system's default
httpd -> /usr/sbin/httpd
nginx -> /usr/sbin/nginx
php-fpm -> $HOME/opt/sbin/php-fpm
php-fpm.orig -> /opt/remi/php80/root/usr/sbin/php-fpm
start -> start-httpd
stop -> stop-httpd
3. Building & enabling Xdebug
There's good tool at http://xdebug.org/wizard to refer which may help building the xdebug
The environment variables set at the beginning of the steps are important to tell the compiler to build xdebug against the correct version of PHP.
export CPPFLAGS="-I$HOME/opt/include $CPPFLAGS"
export LDFLAGS="-L$HOME/opt/lib $LDFLAGS"
tar zxf xdebug-3.1.2.tgz
~/opt/lib/php.ini with the following line
zend_extension = $HOME/xdebug-3.1.2/modules/xdebug.so
4. Validate the config
phpinfo(); into some sample .php file at php-app directory
You should able to see XDEBUG module enabled in the browser output
Good luck and Happy debugging.
Thanks @sean for your patience and guidance getting this.