Install PHP5, MySQL, Apache on Ubuntu 12.04

I will show you how to install a LAMP system. LAMP stands for Linux, Apache, MySQL, PHP. The guide is intended to help those who have very little knowlegde of using Linux.

Install Apache:

To install Apache run this command –

sudo apt-get install apache2

Testing Apache

To make sure apache installed correctly enter this URL or your web browser.


Then you will see a message saying “It works!” . That means Apache is running in your machine.

Install PHP

For install PHP5 run this command –

sudo apt-get install php5 libapache2-mod-php5

Then restart apache with this command

sudo /etc/init.d/apache2 restart


sudo service apache2 restart

Test PHP

To ensure that PHP is install correctly create a file named test.php in /var/www

Copy/Paste this line into the test file:

<?php phpinfo(); ?>

Save and type the following into the web address:


You will get a page with PHP information.

Install MySQL

To install MySQL run –

sudo apt-get install mysql-server

In order for other computers on your network to view the server you have created, you must first edit the “Bind Address”. Begin by opening up Terminal to edit the my.cnf file.

gksudo gedit /etc/mysql/my.cnf

Change the line

bind-address =

And change the to your IP address.

You should skip this step if you running Ubuntu on your local machine.

Now enter into MySQL and run –

mysql -u root

And then run this command –

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');

(Make sure to change yourpassword to a password of your choice.)

Now install other necessary packages for your LAMP development environment.

Run this command –

sudo apt-get install build-essential php5-curl php5-gd
php5-mysql php5-xdebug php-pear php5-memcache memcached

That’s it. Enjoy the power of PHP and MySQL.
Happy Coding 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s