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?
2 Answers
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.
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.
-  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 theapt-get install libapache2-mod-php5will make all of these changes for them.Kyle Smith– Kyle Smith2011-01-21 18:05:46 +00:00Commented Jan 21, 2011 at 18:05
-  The OP did not specify the installation method and/or current configuration.Khaled– Khaled2011-01-22 07:51:15 +00:00Commented Jan 22, 2011 at 7:51