# Setting up php in apache2

There is probably a very simple solution for this particular issue, alas I ether have yet to find it or understand the solution if I did find it.

Our server is Ubuntu 12.04. Apache2 is set up and currently hosting a number of websites without an issue, none use php. Now I am attempting to add a new website that is run on php.

I have looked for a general setup guide for php but thus far have found nothing. I have made sure php module is enabled within apache2, but when I try to load a test PHP file it fails.

PHP5 is installed, apache2ctl configtest shows the syntax is correct.

Can anyone help me with this one?

Edit: It fails by showing a blank screen with the phptest.php file. I have also tried using a helloworld.php test file. Both show blank, I have yet to check the apache log, I will do that asap. Thanks for giving me a lead, ill update this soon.

• How does it fail? – Zypher Apr 24 '14 at 21:41
• If you create a test.php file with contents: <?php phpinfo(); ?> , what does it show on browser? and in apache error.log? – LinuxDevOps Apr 25 '14 at 0:51

OK, so basically you need to install the php5 package through apt-get. When you do that, you need to enable the php5 module by running the following as root:

a2enmod php5


Then open your apache configuration or virtual host configuration and add the line:

 AddType application/x-httpd-php .php


Then restart apache by running the following as root:

 service apache2 restart


If this does not work, you check the logs in /var/log/apache2. Paste last 100 lines of error.log here.