On Debian (and thus Ubuntu), the Apache configuration files are stored under /etc/apache2
. In that directory, there are 2 sub-directories for configuring modules: mods-available
and mods-enabled
. When you install an Apache module (ie: foo), it will put foo.load
(and possibly foo.conf
) into the /etc/apache2/mods-available
directory. When you enable an Apache module using a2enmod
, it will create a symbolic link in /etc/apache2/mods-enabled
for each of the matching files from /etc/apache2/mods-available
.
Thus for an Ubuntu server with PHP5 enabled, you should see something like this:
$ cd /etc/apache2
$ ls -l mods-*/*php*
-rw-r--r-- 1 root root 133 2008-02-27 15:49 mods-available/php5.conf
-rw-r--r-- 1 root root 59 2008-02-27 15:49 mods-available/php5.load
lrwxrwxrwx 1 root root 27 2009-02-05 07:30 mods-enabled/php5.conf -> ../mods-available/php5.conf
lrwxrwxrwx 1 root root 27 2009-02-05 07:30 mods-enabled/php5.load -> ../mods-available/php5.load
If the php5 configuration files aren't shown in the mods-enabled
directory, enable them as follows:
$ sudo a2enmod php5
$ sudo /etc/init.d/apache2 restart
Once you've done that, in order to test that PHP5 is configured, create /var/www/test.php
as follows:
$ echo "<?php phpinfo(); ?>" | sudo tee /var/www/test.php
$ sudo chown www-data:www-data /var/www/test.php
$ sudo chmod 755 /var/www/test.php
Once that's done, you should be able to browse to /test.php
on that server and see the PHP configuration data.
I am getting permission denied for this line
$ sudo echo "<?php phpinfo(); ?>" > /var/www/test.php
. – 151291 – 2016-02-23T04:49:08.243@151291, try
echo "<?php phpinfo(); ?>" | sudo tee /var/www/test.php
instead. – Craig Trader – 2016-02-24T12:55:13.523