Why is php not running? Why is php not running? apache apache

Why is php not running?


Check out the apache config files. For Debian/Ubuntu theyre in /etc/apache2/sites-available/ for RedHat/CentOS/etc they're in /etc/httpd/conf.d/. If you've just installed it, the file in there is probably named default.

Make sure that the config file in there is pointing to the correct folder and then make sure your scripts are located there.

The line you're looking for in those files is DocumentRoot /path/to/directory.

For a blank install, your php files most likely needs to be in /var/www/.

What you'll also need to do is find your php.ini file, probably located at /etc/php5/apache2/php.ini or /etc/php.ini and find the entry for display_errors and switch it to On.


One big gotcha is that PHP is disabled in user home directories by default, so if you are testing from ~/public_html it doesn't work.Check /etc/apache2/mods-enabled/php5.conf

# Running PHP scripts in user directories is disabled by default# # To re-enable PHP in user directories comment the following lines# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it# prevents .htaccess files from disabling it.#<IfModule mod_userdir.c>#    <Directory /home/*/public_html>#        php_admin_flag engine Off#    </Directory>#</IfModule>

Other than that installing in Ubuntu is real easy, as all the stuff you used to have to put in httpd.conf is done automatically.


To answer the original question "Why is php not running?"The file your browser is asking for must have the .php extension.If the file has the .html extension, php will not be executed.