I recently installed xdebug
on my server but restricted it's use to our test site, which uses it's own php.ini
file.
For example, the test sites php.ini
is located at:
/home/test_site/public_html/subdomain_name/php.ini
Inside this php.ini
file I have the below for xdebug:
[XDebug]
zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = /home/test_site/xdebug
xdebug.profiler_output_name = "cachegrind.out.%s-%u.%h_%r"
Now, the thing is, xdebug works fine, no problems.
However, on our main site, which also has it's own php.ini
file, which is located for example at:
/home/main_site/public_html/php.ini
Inside this file I have nothing for xdebug
in there.
Now, I recently setup a cron in cpanel for the main site
such as:
php -f /home/main_site/public_html/cron_jobs/main_cron.php > /home/main_site/public_html/logs/main_cron.log 2>&1
Now, upon checking the output of the cron inside the log file I get the output:
Failed loading xdebug.so: xdebug.so: cannot open shared object file: No such file or directory
Why am I getting this error when the main site shouldn't even be loading xdebug?
Even though you have the two sites split up and using two different php.ini files, CRON will still use whichever php.ini file the PHP-CLI is configured to use. So, to figure out which php.ini CRON is using, this is the command to use:
php -i | grep php.ini
If PHP-CLI happens to be using a php.ini file that you didn't expect it to be using (such as /usr/local/lib/php.ini
) then that will be the key to figuring out why you're seeing Xdebug errors in the logs.
It turns out that the /usr/local/lib/php.ini
file had these two values set:
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20090626"
zend_extension = "xdebug.so"
That was causing the error from the php script that was run by CRON (i.e. PHP-CLI) because zend_extensions need the full path to the module. This is also stated in the Xdebug documentation: http://xdebug.org/docs/install
So, to get rid of the error, just comment out that line (or just remove it). You could also comment out or remove the extension_dir
line as long as you are not loading any other modules such as:
extension = memcached.so
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With