Installing Apache2 and PHP5 on Ubuntu
Installing Apache2 and PHP5 on different platforms can be frustrating at times because of the differences involved in each platform. Especially true when you are new to a particular Operating System. Just today I had to install both these two software on my fairly newly installed Ubuntu laptop. And it took me some effort to accomplish that, which for an experienced user would have taken minutes. For those of you who might travel on this road too, here is the quick way to get Apache and PHP5 running on your Ubuntu computer.
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart
Note: You may need first to add the extra repositories to your Ubuntu source.list file. This can be found in /etc/apt/sources.list. You need to comment out the following lines in the file:
deb http://security.ubuntu.com/ubuntu dapper-security universe
Once you have done that, run this command.
After installing both Apache and PHP5, you will need to configure Apache for PHP5. To do that, these are the steps:
- Using a text editor, in /etc/apache2/conf.d, create a file called php.conf
- Your php.conf will contain the following lines
#
# Load the apache module
#
LoadModule php5_module modules/libphp5.so
#
# Cause the PHP interpreter handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php
Restart your apache server.
Post new comment