On Ubuntu 8.10, I ran into a bit of problem. The Apache web server was working fine, but the following commands:
sudo apt-get install php5 libapache-mod-php5 sudo /etc/init.d/apache2 restart
failed to work after creating a phpinfo.php file in the /var/www/ root folder. Firefox complained, “You have chosen to open phpinfo.php which is a: PHP file.” Apache was not using the PHP preprocessor for some reason. A bunch of forum posts and blogs said to edit either /etc/apache2/httpd.conf or /etc/apache2/apache2.conf in order to associate the PHP mime type with the file extension. That wouldn’t work because I had also installed phpmyadmin which has an apache.conf file that already has an AddType directive. So, after some digging around, it turns out the module wasn’t even being loaded, even though that’s what you’d expect the package manager to handle when you tell it to install the module. Any how, to fix the problem, just create symbolic links to the php5.load and php5.conf files in the /etc/apache2/mods-enabled/ folder.
sudo ln -s /etc/apache2/mods-available/php5.load /etc/apache2/mods-enabled/php5.load sudo ln -s /etc/apache2/mods-available/php5.conf /etc/apache2/mods-enabled/php5.conf sudo /etc/init.d/apache2 restart
Update: Debian-based installs of Apache2 have some handy command line utils for managing the web server. So to enable a mod, which automates the above, do this instead:
sudo a2enmod php5
a2dismod is the command for disabling a mod. For sites, there is also a2ensite and a2dissite.