Installing Apache, PHP, MySQL and phpMyAdmin on Ubuntu 8.10

[Note: In this post I'll be showing how to install Apache, php, MySQL and phpMyAdmin (one by one) on Ubuntu 8.10 using Terminal. If you want to install them all at the same time with minimal fuss, I recommend you to read my post on installing LAMP.]

Installing Apache

1. Open Terminal (Application -> Accessories -> Terminal) and execute the following command:

sudo apt-get install apache2

2. When the setup is complete you can check if the Apache is working properly by pointing your browser to http://localhost. If you see the text “It works!”, it means Apache is working just fine.

3. Towards the end of the installation if you see a message like this inside Terminal, “Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName“, you can fix this by executing the following command. It will open Gedit (text editor).

gksu gedit /etc/apache2/conf.d/fqdn

4. When Gedit opens, type “ServerName localhost” inside the file and click Save. Then close the file.

Installing php5

1. Inside Terminal, execute the following command:

sudo apt-get install php5 libapache2-mod-php5

2. When setup is complete, you have to restart Apache so that php5 will work on Apache. Execute the following command in Terminal:

sudo /etc/init.d/apache2 restart

3. You can now test to see if php5 works with Apache. To do this you can create a new php file inside your /var/www/ folder. (The text in red is the filename. You can put any name.)

sudo gedit /var/www/nass.php

4. The command above will open Gedit. Just type in the following php code, save and close the file:

<? phpInfo(); ?>

5. Now point your browser to “http://localhost/nass.php” and see if you can see the text “yoo hooo!” and a lot of information about your php5 installation. If you see that, it means your have successfully installed php5.

Installing MySQL

1. Inside Terminal, execute the following command:

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

2. Towards the end of the installation you will be prompted to set your root or admin password (see pic below)

set root password

Installing phpMyAdmin

1. Inside Terminal, execute the following command:

sudo apt-get install phpmyadmin

2 During the installation you will be asked to select the webserver that would be used to run phpMyAdmin. Select Apache2 (see pic below).

choosing webserver

3. After the installation is over execute the following command to copy the phpmyadmin folder into the /var/www/ directory. (By default it is installed in /usr/share/phpmyadmin/ directory.)

sudo ln -s /usr/share/phpmyadmin/ /var/www/phpmyadmin

4. Now you can go to the phpMyAdmin login page by pointing your browser to: http://localhost/phpmyadmin/index.php

The username for MySQL and phpMyAdmin is “root”. The password will be what you set in step 2 (under installing MySQL).

That’s it! Now you’ve successfully installed Apache 2 webserver, php5, MySQL and phpMyAdmin on Ubuntu.

UPDATE (28-Jan-09)

After installing Apache, PHP, MySQL and phpMyAdmin, you can install support for ASP.NET files in Ubuntu. Don’t worry, you will be able to work with php and aspx files on the same Apache server without any problems.

[References: Ubuntu Community Docs & HowToForge]

83 Responses to “Installing Apache, PHP, MySQL and phpMyAdmin on Ubuntu 8.10”

  1. Ray Says:

    Thank you for the information it was very helpful. My next step is to get tomcat running.

    -Ray

  2. MechanisM Says:

    hmm..all installed succesfully..but I have an error!!
    “cannot load MySQL extension, please check PHP Configuration”.

  3. Lawal Adekunle Says:

    hello Mechanism. have you edited the php.ini file. do a
    sudo gedit /etc/php5/apache2/php.ini

    look for the line that says extension=mysql.so and uncomment it by removing the ; in front of the line. restart the apache service and hold your breath.

  4. Adam Says:

    I’ve installed it and logged in. Thanks!
    However, there were two problems:

    1. In step 4 of Installing PhP, we are to put in:

    I had to change the quotation marks from whatever is here to whatever they are in Gedit. Then it worked.

    2. With reference to MechanisM’s problem, Lawal’s solution does not quite work. In the php.ini file, there appears to be an error. In the file, I can find:
    extension=msql.so
    but not:
    extension=mysql.so
    Uncommenting:
    extension=msql.so
    does not work. It must be uncommented and changed to:
    extension=mysql.so
    then it works fine.

    One final comment. The instructions are clear about making a new password for MySQL for the “root” user. However, it might be noted that in logging into phpMyAdmin, the user name is root, then the password as given. Perhaps this is obvious, but perhaps it is worth mentioning; I thought the username would be the user name I log into my ubuntu machine with.

    Thanks for this! After these minor glitches, it works so far. Glad to have it!

    Cheers,
    Adam

  5. nass Says:

    @Adam

    I’ve removed that bit in the quotes as it’s not even necessary.

    As you’ve mentioned, some users may not know what to use as the username. So I’ve put that in as well.

    Thanks for the comment.

  6. tarantullas Says:

    thanks, there are no problem
    for those who have problems, please restart apache to function properly

  7. neeltje57 Says:

    Worked perfectly, thanks.

  8. WordPressHacker Says:

    Awesome! So easy to follow! I really appreciate the time you put into this.

    To anyone getting the same error as MechanisM with phpmyadmin, follow Adam’s instructions, and then make sure you type localhost/phpmyadmin/index.php again in the address bar. I stupidly kept hitting reload and it kept reloading the error page even though the problem was solved.

    Thanks everyone!

  9. Michael Sharman - chapter31 » Development configuration tips for Ubuntu Says:

    [...] assumes you’ve already installed Apache and MySQL, for notes on installing these I found this article to be a great [...]

  10. Chris Everson Says:

    @MechanisM

    When making any changes to Apache a restart is required.

    sudo /etc/init.d/apache2 restart

    That should fix’r up.

  11. brad Says:

    After each change, restart fixed the php problem.

    sudo /etc/init.d/apache2 restart

  12. Kirill Says:

    Thanks a lot!!!

  13. rj Says:

    I have to do this every time I format. I’m glad there are people on the net like you that document everything. Thanks a lot man. Happy holidays.

  14. WissMan Says:

    Thank You it’s the Perfect guide for PHP MYSQL APACHE installation processes. it’s the easiest that i have seen .

    Thanks again

  15. Geltonas Says:

    thanks a lot, everything is working perfectly!

  16. Jay Says:

    This Worked Out Great Thank You.

  17. LG Says:

    Worked properly. Thanks

  18. DAVID HIEN Says:

    thanks you! i am very happy when read this document.

  19. Brook Says:

    Thank you very much, it is great producre to follow. it work perfect for me

  20. lab69 Says:

    Thank U. It.s very useful.

  21. Sharon Says:

    Excellent … I have got it all working. Thankyou.

  22. nandrito Says:

    thanks for the very nice tutorial.. ;)

  23. Russel Says:

    The tutorial is awesome :D
    I was searching for this kind of Cristal clear instructions for two days and thank God that at last I found it :)
    I’ve become a fan of this site :)

  24. nass Says:

    Thanks for the comments everyone :)

  25. waver Says:

    hai. i’m a total noob when it comes 2 linux let alone running a server on it. i was able to install apache using your guide (thanks a bunch by the way) but i was unable to customize so to say my webpage layout. i only know how to edit html pages. i tried editing the index.html file thats on /var/www but i don’t have permission. could anyone help me….

  26. Rubel Says:

    Thanks nass. Its very useful.

  27. Russel Says:

    hello waver… type “sudo nautilus” in your terminal and then press enter… it will open the root file browser… from this browser right click on the folder /var/www and select properties from context menu… then select permission tab and then edit the owner and group :) thats all :)

  28. ColdAdvice Says:

    Thanks nass. I installed apache and php5. It worked great. But when running my php scripts, it ignores all the “\n” line feeds. (The HTML works.) Any idea why the “\n” doesn’t work? I don’t think I changed any settings.

  29. feymman Says:

    Hello! I’m new on Ubuntu Intrepid Ibex and I want to Know if it is necesary to install Ubuntu Server? Or all discussed above is usefull on Ubuntu Desktop?

  30. prometeo Says:

    Thanks a lot for this extremely simple yet funcional and working tutorial!!!

    Great job!

  31. Arun Says:

    Help me I forgot my password for phpmyadmin, any way to recover username and pass both :(
    - arun

  32. Javier Garay Says:

    Exelent work my friend…

    I installed everything whitout problems..

    thanks and keep the way!…

    Greatings

  33. Coffecup Says:

    Worked like a charm. Did have to edit php.ini file as indicated in other comment but this is by far the simplest explanation out there

  34. ridho Says:

    i was try and it work

    goot info

    thank you

    regards

  35. Kellerman Says:

    Thanks a lot!!!!!!!!!!

  36. prasant Says:

    Excellent Article.You rock man. Thanks…

  37. Kenchan Says:

    Awesome article!!! Thank you :)

  38. Brad Says:

    Awesome tutorial, thank you so much.

  39. arupphala Says:

    thank you.. it works perfectly

  40. Si Newbie Says:

    Terima kasih, sangat membantu. Segalanya sekarang menjadi terang. Bravo!

  41. Denis Bahati Says:

    Thanx for your document,it helped me very much in installing my apache,php and mysql.

  42. Denis Bahati Says:

    wow wow,its wrong time I was finding the solution for “Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName“,now got it. Thanx alot.

  43. Binu Mathew Says:

    Sir,
    i installed the XAMPP in my ubuntu 8.10 sucessfully,but sir i cant able to copy any of the file to /opt/lampp/htdocs/ folder why this happening

    i am a beginner in both PHP and Linux, can u explain me…plz….waiting for your response

  44. Renato Chea Says:

    wwwwwwwwwwowwwwwwwwwwwwwwwwwwwwww great tutorial :D !!!! :D
    greets from Guatemala

  45. RahulC Says:

    A very clean and precise set of instructions, I could install all of it without any problems. Extremely good job done.

  46. Clarence Pinto Says:

    Newbie to Ubuntu 8.10.
    Perfect & clear instructions. Everything worked.
    Thank you.

  47. James Sun Says:

    Let me join the many others in thanking you for this great tutorial! Your instructions were so good even a Micro$oft guy like me can follow them :-)

  48. leigh Says:

    Great tutorial. Reads like you are a technical writer. It’s rare! I’ve been spending hours on forums since I’ve installed Linux and usually it’s ambiguous or cryptic. Nice change.

  49. Alex Says:

    Its tutorials like this that pop up #1 on a google search that will make ubuntu a dominant operating system. That and apt-get.

  50. TheJester Says:

    Very nice work on the tutorial friend. :) Keep up the good work!! Thnx ^^

  51. j3ko Says:

    one of the cleanest how-to’s out there, everything worked as expected w/ no surprises…very nice work :)

  52. Vinicius Says:

    Nice, very nice! : )

  53. Pedro Mendes Says:

    Tks guy, You help me a lot!

  54. MimisRE Says:

    Thanks a lot…everything works perfect…

    Chears Mate

  55. Everton Says:

    Thanks very much friend! Excellent tutorial!

  56. BenBen Says:

    Thank you very much for your effort

    but unfortunately i have a small problem that when i click on the link http://localhost/phpmyadmin/index.php
    it gives me an error

    “Cannot load mysql extension. Please check your PHP configuration. – Documentation”

    could any one please answer me and tell me what to do

    any answer will be highly appreciated ;)

  57. Ammar Says:

    Thanks a lot

  58. Vega Linux Says:

    All, I have the error when i’ll try to LogIn to PHPmyAdmin the error was “Error
    #2002 – The server is not responding (or the local MySQL server’s socket is not correctly configured)”,

    any suggestion?

    vegalinux@yahoo.co.id

  59. Alex Says:

    i get an error as well! :(
    Cannot load mysqli extension. Please check your PHP configuration. – Documentation

    i went to the file that you said, uncomented the thingy and also changed it to mysql insteat of msql but is not working.

    Also i think that could be because after step
    Installing phpMyAdmin
    it asked me for something else that is not mentioned here.
    About if i want to use a dbcommon about a database or if i want to do it myself afterwards…and because i said yes then it was a couple of more passwords asked. :/

    So now it resulted to this.
    Can somebody help?
    Thenx

  60. Alex Says:

    p.s. restart php again and now it works and i log in
    But still there is this error bellow where the login credentials are asked!
    Can i do smthing about that?

    Thank you again in advance!

  61. rick Says:

    Ubuntu 8.10 Using Firefox 3.0.10

    Apache works html file says “It Works”

    http://localhost/rick.php – Firefox wants to Open File or Save it. Will not run it. Is this a Firefox problem or a php5 problem?

    Great tutorial !!

  62. rick Says:

    Sorry people. I messed around with the apache2.conf, httpd.conf files and Firefox now works.

    Thanks for listening!!

    R

  63. Anoop Nair Says:

    Thanks lot……….its also working properly in ubuntu 9.04

    Hats off to provide such a good and simple tutorial

  64. designcode Says:

    I just installed the whole stuff, using the great tutorial you wrote, LAMP is now working on my side ;) .

    Thanks for sharing the skills.

  65. Roger Says:

    Rick,

    I am having the same problem with firefox wanting to open file or save the php file. Can you tell me what did you do to fix it please.

    Roger

  66. Amol Says:

    Ya……….
    Really great………
    Instructions are extremely suitable & perfect.
    I’d done job quickly & eaisly.
    Thanxs a lot…………..

  67. EachOnSet Says:

    Just followed your walkthrough on Ubuntu 9.04 and it worked like a charm!

    Many thanks!

  68. Indranil Says:

    Hey! Thanks man. Your article was a great help. Do you have something similar for Ruby? Thanks anyways

  69. Abu Unais Says:

    OK, thanks for your tutorial. I’m Newbe and your experiment is usefull.

    Thanks a lot

  70. amko Says:

    Thank you. This worked perfectly for me.

  71. eldileepa Says:

    thanX…u help me very much from this

  72. Installing LAMP on Ubuntu 8.10 - PlazaKomputer.Net Says:

    [...] by Administrator on Jul.05, 2009, under How-To Installing Apache, PHP, MySQL and phpMyAdmin on Ubuntu 8.10 [...]

  73. tanmai Says:

    To this list of innumerable thank yous, I add another one.

    Thanks a lot.

  74. Navjot Singh Says:

    Thanks for the tip. It worked wonderfully.

  75. saeed ahmed Says:

    assumes tutorial… its works successfully…thanks

  76. 1Anônimo (1anonimo) 's status on Saturday, 15-Aug-09 13:06:16 UTC - Identi.ca Says:

    [...] seguindo os passos do site http://ubuntuexperiment.wordpress.com/2008/11/10/installing-apache-php-mysql/ [...]

  77. Installing Apache, PHP, MySQL and phpMyAdmin on Ubuntu 8.10 « the ubuntu experiment | My Web Development Bookmarks Says:

    [...] Visit link: Installing Apache, PHP, MySQL and phpMyAdmin on Ubuntu 8.10 « the ubuntu experiment [...]

  78. Denis Says:

    Perfect article. It helped me a lot!!!!
    Thanks!!!!!!!!!!!!

  79. chris O Says:

    What an absolute star you are. I have been playing around with php now for some months and newly installed ubuntu on my desktop. This is such an easy guide to follow.

    Thanks ever so much

  80. Frankline Says:

    Thanks a lot. I just installed Ubuntu 9.04 and installed LAMP on it. It works like a charm. Thanks again.

  81. Srinidhi SA Says:

    Thank you very much for posting this article……..

  82. best wp theme Says:

    thanks for your article, its help me to install AMP in ubuntu

  83. Chris Says:

    Thank you Nass, you’re a star. I like you have been a dedicated follower of Windows but find myself inexplicably intreagued by the Ubuntu thing and the ease of the installs (anyone who has installed this same software on Windows will know what I mean.) So many thanks for the advice

Leave a Reply