Loading...

Installing Apache and PHP5 on Ubuntu

To install Apache and PHP5 on Ubuntu, you will first need to make sure that the restricted repositories are enabled. You will want to edit /etc/apt/sources.list and make sure the following lines are in it and are not commented out with a #. If they are commented out, you will just need to remove the # character.

deb http://us.archive.ubuntu.com/ubuntu/ natty multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ natty multiverse
deb http://us.archive.ubuntu.com/ubuntu/ natty-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ natty-updates multiverse
deb http://security.ubuntu.com/ubuntu natty-security main restricted
deb-src http://security.ubuntu.com/ubuntu natty-security main restricted
deb http://security.ubuntu.com/ubuntu natty-security universe
deb-src http://security.ubuntu.com/ubuntu natty-security universe
deb http://security.ubuntu.com/ubuntu natty-security multiverse
deb-src http://security.ubuntu.com/ubuntu natty-security multiverse

Once that is done, you will want to run this command to update all of your repositories.

sudo apt-get update

Then we can start installing Apache and PHP. First we want to install Apache:

sudo apt-get install apache2

Then PHP5:

sudo apt-get install php5

We will also need the module to allow Apache to run PHP.

sudo apt-get install libapache2-mod-php5

After that, everything is done, we just need to restart apache to allow the module to load.

sudo /etc/init.d/apache2 restart

You can then verify that Apache is running by using the following command.

/etc/init.d/apache2 status

And also check PHP by running this command:

php -v

You should now have Apache and PHP up and running. The default document root for Apache2 is /var/www. You can begin putting your files there to be served to the internet.

Leave a Reply

Your email address will not be published. Required fields are marked *

*