Setting Up a LAMP Server In Ubuntu Hardy Heron

LAMP stands for Linux, Apache, MySQL and PHP. It is the most widely used combination for setting up a Web Server. By far, the easiest way to install LAMP server is simply installing the Ubuntu Server Edition itself. However, many of us have installed the Ubuntu Desktop edition, only to find that we need to set up a LAMP server later on. In the following tutorial, I am going to show you how to install and configure a LAMP server in your Ubuntu Hardy Heron in less than 10 minutes.

Installing Apache, Php and MySql

In your Ubuntu desktop, go to “System -> Administration -> Synaptic Package Manager”.

Scroll down the list to search for “apache2”. Check the box beside it and select “Mark for installation”. This will also install other dependency packages. When prompted, click “Mark”.

Apache in Synaptic Package Manager

Next, scroll down the list and search for “php5”. Similarly, place a check beside the box and select “Mark for installation”.

PHP5 in Synpatic Package Manager

Do the same for “mysql-server” and “phpmyadmin”.

MySQL in Synpatic Package Manager

phpmyadmin in Synpatic Package Manager

Once you are done, click “Apply” on the top icon bar.

The Synaptic Package Manager will now fetch all the files and install it in your Ubuntu.

When installing MySQL, you will be prompted to enter and reconfirm your password. Make sure that you enter a password that you can remember.

Setting mysql password

Also, the “phpmyadmin” will ask you which version of apache to use. Select “apache2”.

Configuring Phpmyadmin

Testing your installation

Once you have finished installing the LAMP, you will need to test if it is working.

Open your browser and point the URL to http://localhost

If you see the words “It works”, then apache is working fine.

Testing Apache

Next, you want to create a php file to test your “php” setting.

paste the following line to the file

Save and close the file.

In your browser, point the URL to http://localhost/testphp.php. You should see all the php information on the browser. If it prompt you to download the file, then your php configuration is not successful. Go to Synaptic Package Manager and reinstall “php5”.

Testing PHp

Testing of phpmyadmin

On your browser, go to http://localhost/phpmyadmin. It should loads up the phpmyadmin login page. Log in with the user name “root” and the password you supplied when installing.

phpmyadmin login page

This will bring you to the main screen of phpmyadmin.

Putting it all together

To test if the “apache, php5, MySQL” and “phpmyadmin” are working together, we can test it out by installing WordPress.

Download WordPress here.

Extract the “wordpress” folder to your home folder.

Inside the folder, open up the “wp-config-sample.php” file. Edit the following information.

Remember to change the “yourpasswordhere” to the password that you supplied during the MySQL installation.

Save the file as “wp-config.php”.

Next in your phpmyadmin, create a new database call “wordpress”.


Open a terminal, copy the wordpress folder to the apache working directory (the working directory is located at “/var/www”)

Once done, on your browser, go to http://localhost/wordpress. The famous 5 minutes installation will show on screen. Follow the instructions. If is your LAMP configuration is good, your WordPress will be up in 1 minute.

That’s it. Enjoy!

Damien Damien

Damien Oh started writing tech articles since 2007 and has over 10 years of experience in the tech industry. He is proficient in Windows, Linux, Mac, Android and iOS, and worked as a part time WordPress Developer. He is currently the owner and Editor-in-Chief of Make Tech Easier.


  1. I just completed the whole thing per your instructions from a Crux 2.4 box, sshing into Ubuntu Hardy and using Links2! Everything went without a hitch. Just one caution though for new users, be sure to cd back into your home directory before doing: sudo cp -R wordpress /var/www/. As I had forgotten I was still inside the wordpress directory from previous file editing, the command brought about a “file not found,” A minor panic before I realised what I needed to do.

    A great instruction! Thank you so much for this!!

    Dapper Dan

  2. Thanks! I’ve always wanted to try this locally and I couldn’t seem to make it work. This took me about five minutes, not counting time it took to download packages.

  3. When I installed mysql, instead of the gui interface for mysql setup, it was all done in the command line. I followed the steps as they were setup, but in Synaptic, I had to click the “Show Details” option when the installation was going so that I could answer the questions. This may not be typical, but just something to watch for

  4. Great tut very easy to follow. Ive always wanted to get a server started with ubuntu, but how do i create my own domain, using dns or static ip or whatever, thats where im really lost.

  5. HI,
    Everthing worked UNTIL the end… when going to localhost/wordpress the configuration process says
    “There doesn’t seem to be a wp-config.php file. I need this before we can get started. Need more help? We got it. You can create a wp-config.php file through a web interface, but this doesn’t work for all server setups. The safest way is to manually create the file.”

    Then i click on CONFIGURATION and i get …

    Sorry, I can’t write to the directory. You’ll have to either change the permissions on your WordPress directory or create your wp-config.php manually.”

    Running xubuntu 8.04. Help? thanks

  6. Thanks for the tute…
    Quote “If it prompt you to download the file, then your php configuration is not successful. Go to Synaptic Package Manager and reinstall php5” This is the issue that I have… so I removed everything PHP5 related (purged) then reinstalled… I tested http://localhost/testphp.php and it worked perfectly then I tried to http://localhost/phpmyadmin and it prompted me to open/download the package again ??? Any ideas what is screwed…

  7. Wow, it is amazing how complicated people make things, but you made this so easy to understand and do its incredible! Thank you very much!

    I am having one problem though… in theory someone should be able to type in my ip address and they should see the “It works” webpage right? I am unable to get it to work… :(

    1. That is provided you are accessing it from the same LAN or network (means http://localhost, or depending on your router). You will need to do a DNS binding to access from public network.

  8. Hey thanks ,absolutely great tutorial..I got it done no problem.I dont think I would have figured all that out myself.

    rcolson…..when you edit the “wp-config-sample.php” file and input password etc you must then save the file as “wp-config.php”.
    Just delete the word -sample …I made the same mistake but figured it out.

  9. Great tut! Especially because it worked, unlike my solo effort. The exact instructions about *which* of the many apache, mysql, etc., files to install, and the screenshots make all the difference, and stopped me from making a couple of stupid mistakes.

    Instead of wordpress, I tried Mediawiki. Good fun!

  10. that’s one quick run of tutorial.
    i did it the way you described it on this tutorial
    and, boom! it worked.

    how about a LAMP in ubuntu 8.10.

  11. I was following the tutorial, and it worked flawlessly, until I got to the part about phpMyAdmin. Whenever I try to login with root as username and my password, I get the error:

    “#1045 – Access denied for user ‘root’@’localhost’ (using password: YES)”

    Any help would be appreciated!


  12. Hi…Damien,
    thanks for this tutorial, its works on my HH 8.04, but its doesn’t works on my Intrepid 8.10
    I do exactly as you told… but I’ve got trouble when try to entering testphp and phpmyadmin, it says and it prompted me to open/download the package, not showing the site…
    I try to reinstalling it but problems still persists, I try to uninstall everything and installing again the same problems still there.
    please help me/us how to solved this problem
    thanks you Damien…

    1. The installation should work in Intrepid.

      Try this: go to the folder /etc/apache2/mods-available and copy the two files: php5.conf and php5.load to the folder /etc/apache2/mods-enabled. Test on your browser again and see if it works.

      1. Hi Damien,
        thanks to replying, but nope… it s doesn’t works ;))
        but sure your tutorial is work fine in my other computer and it is using intrepid, only this one at my office it didn’t works.
        ooohh… maybe ‘coz i use it as server for sharing bandwidth and ssh networking to other 10 pc :D (its might?)
        if it is can be works on this situation, would you like to show me how Damien? if not, its ok…
        Thanks again… and I’ll try to follow your great tutorials

  13. Excellent article! Thanks!
    I followed it exactly and the whole installation completed without problems.
    Thanks for taking the time to write this.

  14. I did everything you said, everything worked except the last part.

    I did this: http://localhost/wordpress/

    and I got this: Forbidden

    You don’t have permission to access /wordpress/ on this server.
    Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.1 with Suhosin-Patch Server at localhost Port 80

  15. thanks for such a nice tute…..
    you are really making tech easier….

    i want to start programming with linux..i just want to know which language is better to start as a beginner….plz tell..

  16. I encountered a problem with the installation of mysql server. The error listed is this E:/var/cache/archives/mysql-server_5.01a-3ubuntu5.1_all.deb:
    subprocess pre-installation script returned error exit status 1. I tried reinstalling and got the same message? Any help would be appreciated.

  17. hiiii… i need help. i just followed ur instruction and installed everytin succesfuly. but i cant seem to create the testphp.php file in the www folder. i used the command you gave out, it asked me to enter a password and i did. after that i checked to see if the file has been created in the folder but didnt see it. i also tried to access the file from the address bar as u said but i had dis “Not Found

    The requested URL /testphp.php was not found on this server.
    Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.1 with Suhosin-Patch Server at localhost Port 80 ”

    any help plsssss.

Comments are closed.