Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Mar 202010
 

Install Xdebug for PHP under Ubuntu

Answer:

Xdebug is a very useful debugging extension for PHP, to install under Ubuntu:

# sudo pecl install xdebug
# echo "extension=xdebug.so" > /etc/php.d/xdebug.ini

Restart Apache and that's all.

Feb 142010
 

How to prevent PHP script from running in Apache

Answer:

If you have a PHP script and want it run under in command line only, not in the web server context, you can use the following method.

<?php

if ( php_sapi_name() != "cli" ) {
    print "This script must be run from the command line\n";
    exit();
}