Setting Up a LAMP Server In Ubuntu Hardy Heron

LAMP

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.

gksu gedit /var/www/testphp.php

paste the following line to the file

<?php phpinfo(); ?>

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.

define(‘DB_NAME’, ‘wordpress’);    // The name of the database
define(‘DB_USER’, ‘root’);     // Your MySQL username
define(‘DB_PASSWORD’, ‘yourpasswordhere’); // …and password

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.

phpmyadmin-new-db

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

sudo cp -R wordpress /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!

[Reference: Lijamex's Blog, Howto Forge]

  • Gullit

    Great article!
    Keep doing this nice work man! ;)
    Thanks!

  • Gullit

    Great article!
    Keep doing this nice work man! ;)
    Thanks!

  • http://machopowerwagon.com/ Dapper Dan

    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

  • http://machopowerwagon.com/ Dapper Dan

    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

  • http://machopowerwagon.com/ Dapper Dan

    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

  • http://machopowerwagon.com Dapper Dan

    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

  • Pingback: Setting up LAMP server and Laconica 0.5.0 in Ubuntu Hardy Heron | SaigonNezumi.com

  • http://www.saturados.info/ Edg

    This is amazing! Thank you so much!

  • http://www.saturados.info Edg

    This is amazing! Thank you so much!

  • http://students.iiit.ac.in/~harith harith

    Wonderful. Keep writing mate.

  • http://students.iiit.ac.in/~harith harith

    Wonderful. Keep writing mate.

  • Moon

    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.

  • Moon

    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.

  • Pingback: How To Install And Setup Jinzora Media Server In Ubuntu - Make Tech Easier

  • http://prezbaby.com/ Bill

    Very nice, thanks for the great tute!

  • http://prezbaby.com/ Bill

    Very nice, thanks for the great tute!

  • http://prezbaby.com Bill

    Very nice, thanks for the great tute!

  • http://www.mcflash.net/ nexusgx

    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

  • http://www.mcflash.net nexusgx

    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

  • http://www.mcflash.net/ nexusgx

    probably should have mentioned that that happens in Kubuntu when using Synaptic

  • http://www.mcflash.net/ nexusgx

    probably should have mentioned that that happens in Kubuntu when using Synaptic

  • http://www.mcflash.net nexusgx

    probably should have mentioned that that happens in Kubuntu when using Synaptic

  • Mikhail

    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.

  • Mikhail

    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.

  • http://www.wiki.com/ rcolson9333

    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

  • http://www.wiki.com rcolson9333

    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

  • http://maketecheasier.com/ Damien

    @rcolson9333: Did you edit the wp-config-sample.php file and rename it as wp-config.php?

  • http://maketecheasier.com Damien

    @rcolson9333: Did you edit the wp-config-sample.php file and rename it as wp-config.php?

  • http://www.wiki.com/ rcolson9333

    oops, thanks

  • http://www.wiki.com/ rcolson9333

    oops, thanks

  • http://www.wiki.com rcolson9333

    oops, thanks

  • gsv

    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…

  • gsv

    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…

  • NewUbuntuGuy

    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… :(

    • http://maketecheasier.com/ Damien

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

  • NewUbuntuGuy

    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… :(

    • http://maketecheasier.com Damien

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

  • flattop

    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.

  • flattop

    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.

  • http://molvray.com/acid-test/ quixote

    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!

  • http://molvray.com/acid-test/ quixote

    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!

  • http://molvray.com/acid-test/ quixote

    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!

  • mynameisbob.com

    Very easy to follow. Thanks for the info!!

  • mynameisbob.com

    Very easy to follow. Thanks for the info!!

  • http://koguee.multiply.com/ kervin

    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.
    thanks.

    • http://maketecheasier.com/ Damien

      The above method works for 8.10 too.

    • http://maketecheasier.com/ Damien

      The above method works for 8.10 too.

  • http://koguee.multiply.com kervin

    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.
    thanks.

    • http://maketecheasier.com Damien

      The above method works for 8.10 too.

  • Jimmy

    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!

    Thanks

    • http://maketecheasier.com/ Damien

      Try this on the terminal

      sudo mysql -u root -pxxxx

      where xxxx is your password.

      • Jimmy

        The same problem still persists. It still gives me an error “access denied……”

      • Jimmy

        The same problem still persists. It still gives me an error “access denied……”

  • Jimmy

    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!

    Thanks

    • http://maketecheasier.com Damien

      Try this on the terminal

      sudo mysql -u root -pxxxx

      where xxxx is your password.

      • Jimmy

        The same problem still persists. It still gives me an error “access denied……”

  • http://icemanonweb.blogspot.com/ iceman

    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…

    • http://maketecheasier.com/ Damien

      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.

      • http://icemanonweb.blogspot.com/ iceman

        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

  • http://icemanonweb.blogspot.com iceman

    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…

    • http://maketecheasier.com Damien

      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.

      • http://icemanonweb.blogspot.com iceman

        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

  • http://juteborg.se/ Marcus

    Thanks!

    I wouldn’t manage without this tutorial.
    Truly greatefull.
    Really appreciated.

  • http://juteborg.se Marcus

    Thanks!

    I wouldn’t manage without this tutorial.
    Truly greatefull.
    Really appreciated.

  • http://www.make-a-website-with-traffic.com/ John

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

  • http://www.make-a-website-with-traffic.com John

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

  • Pingback: Make Tech Easier - Setting Up a LAMP Server In Ubuntu Hardy Heron « DevEzine

  • http://xxuriahxx.co.nr Andrew

    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

    • http://maketecheasier.com Damien

      Change the file permission of the WordPress folder

      sudo chmod 755 -R /var/www/wordpress

  • http://xxuriahxx.co.nr/ Andrew

    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

    • http://maketecheasier.com/ Damien

      Change the file permission of the WordPress folder

      sudo chmod 755 -R /var/www/wordpress

  • http://kuldeepsidhu88.blogspot.com/ kuldeepsidhu

    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..

  • http://kuldeepsidhu88.blogspot.com kuldeepsidhu

    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..

  • Mickmoo

    Simple tutorial. Easy to follow. Worked without a hitch. Thanks a lot.

  • Mickmoo

    Simple tutorial. Easy to follow. Worked without a hitch. Thanks a lot.

  • Anonymous

    For the installation part it might be easier to use the “tasksel”-command in CLI (abbr. of task select) (comes with standard installation of ubuntu) and choose “LAMP server” and you are basically set. :D Maybe a nice addition to your tutorial and I found it easier then searching packages. ;-)

  • Anonymous

    For the installation part it might be easier to use the “tasksel”-command in CLI (abbr. of task select) (comes with standard installation of ubuntu) and choose “LAMP server” and you are basically set. :D Maybe a nice addition to your tutorial and I found it easier then searching packages. ;-)

  • Anonymous

    For the installation part it might be easier to use the “tasksel”-command in CLI (abbr. of task select) (comes with standard installation of ubuntu) and choose “LAMP server” and you are basically set. :D Maybe a nice addition to your tutorial and I found it easier then searching packages. ;-)

  • Bob

    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.

  • Bob

    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.

  • kay

    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.

  • kay

    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.

  • Pingback: ???? ????? ???????? ?? ????? ????? ??? ubuntu - ????? ?????? ?????

  • dhanu

    Great & a simple Tutorial
    Works Well
    Thanks a lot.

  • dhanu

    Great & a simple Tutorial
    Works Well
    Thanks a lot.

  • Pingback: Setup a PHP/MySQL Environment on Windows The Easy Way – Make Tech Easier

  • Pingback: How to Create Your Own Torrent Tracker with RivetTracker – Make Tech Easier

  • Rgarcia

    Golden! Everything worked as described.

  • Rgarcia

    Golden! Everything worked as described.

  • Pingback: Run Your own Torrent Tracker with RivetTracker in Ubuntu

Use left/right keys to browse stories.