How to Install LAMP (Linux, Apache, MySQL, PHP) on Ubuntu (8.04 / 8.10)
This is for the newbies in the world of Ubuntu. Use the following steps to install LAMP (Linux, Apache, MySQL and PHP) in Ubuntu.
- Open up the Terminal (Applications > Accessories > Terminal).
- Run the following command to install Apache
$sudo apt-get install apache2
- To test Apache open up any web browser and then enter the following into the web address:
http://localhost/
- Now run the following command in the terminal to install PHP
$sudo apt-get install php5 libapache2-mod-php5
- In order for PHP to work and be compatible with Apache we must restart it. Type the following code in Terminal to do this:
$sudo /etc/init.d/apache2 restart
- In order to test PHP, in the terminal copy/paste the following line:
$sudo gedit /var/www/testphp.php
- Copy/Paste this line into the phptest file: <?php phpinfo(); ?>
- Save and close the file.
- http://localhost/testphp.php
- Once again open up the amazing Terminal and then copy/paste this line:
$sudo apt-get install mysql-server
- This is where things may start to get tricky. Begin by typing the following into Terminal:
$mysql -u root -p
- Following that copy/paste this line:
$mysql> SET PASSWORD FOR ‘root’@'localhost’ = PASSWORD(’yourpassword’);
- We are now going to install a program called phpMyAdmin which is an easy tool to edit your databases. Copy/paste the following line into Terminal:
$sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
- After that is installed our next task is to get PHP to work with MySQL. To do this we will need to open a file entitled php.ini. To open it type the following:
$sudo gedit /etc/php5/apache2/php.ini
- Now we are going to have to uncomment the following line by taking out the semicolon (;). ;extension=mysql.so To look like this: extension=mysql.so
Now just restart Apache and you are all set!
$sudo /etc/init.d/apache2 restart
We are ready to start code in PHP using MySQL for database and Apache as HTTP server in Ubuntu!!!

I am a simple man working in IT field. I love Music, playing soccer, traveling new places. By profession I am a software engineer and enjoy my job. Currently I am doing my M Sc in Software Engineering in Blekinge Institute of Technology, Sweden. I love researching on new technologies such as programming languages, architectures, tools and techniques.
Recent Comments