Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a webserver with apache2 and it seems to run fine . I have also installed php5 on the server .To test if php is working , i have created a test.php with a phpinfo() function call and put this file in /var/www. whenever I point my browser to the php file location it asks me to download the file rather than running it . What's wrong here?

share|improve this question
It would help if you included your Apache configuration file. – carson Jan 21 '11 at 16:58
up vote 1 down vote accepted

For some reason PHP is not running. Make sure:

  • You have restarted Apache after the install
  • PHP is actually loaded into Apache (eg in Ubuntu you need also libapache2-mod-php5 and not just php5)

If both apply, please indeed post Apache config files.

share|improve this answer

There are several things to do:

1- You need to make sure that the appropriate php module is installed. Use; dpkg -l | grep php to list the php related packages.

2- You need to make sure you have a line similar to this in your apache configuration. This line enable the execution of PHP files under specific directory.

AddType application/x-httpd-php .php

3- You just need to reload/restart your apache server after applying the needed changes.

share|improve this answer
In most Debian systems adding these sort of lines is added by modules-enabled and modules-available directory which are handled by a2moden type commands. Typically the administrator shouldn't have to modify apache2.conf directly as the apt-get install libapache2-mod-php5 will make all of these changes for them. – Kyle Smith Jan 21 '11 at 18:05
The OP did not specify the installation method and/or current configuration. – Khaled Jan 22 '11 at 7:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.