[HowTo] Install Apache, PHP, MySQL, and PHPMyAdmin on Ubuntu

After a while i haven’t write on my blog. Now i’m ready to start writing again. Probably you notice that i changed my theme. Yes i was busy redesign my theme from the start. Anyway i will tell you the story on the next article.

Now i want to show you how to install Ubuntu Karmic Koala 9.10 as a perfect server with Apache, PHP, MySql and Phpmyadmin. Since Ubuntu have a great repositories and the magic application called apt-get then it shouldn’t be hard to make Ubuntu as a perfect server.

Okay let’s begin, please make sure your Ubuntu connected to the internet:

  1. Open your terminal and login as root with this command
  2. Update your repositories list:
    apt-get update
  3. Install Apache:
    apt-get install apache2 apache2.2-common apache2-doc apache2-mpm-prefork apache2-utils
  4. Install PHP:
    apt-get install php5 libapache2-mod-php5 php5-common php5-gd php5-mysql php5-imap php5-cli php5-cgi php-pear php-auth
  5. Install MySQL:
    apt-get install mysql-server mysql-client

    here you will be ask to input root password for the mysql

  6. Install PhpMyAdmin:
    apt-get install phpmyadmin

    here you will be asked some question to configure the phpmyadmin, just go through the wizard after it finish installed.

  7. Now your server is ready. Before you test please make sure to restart the server:
    /etc/init.d/mysql restart
    /etc/init.d/apache2 restart
  8. Open document root in /var/www , make a file called it with info.php
    and fill this:

    <?php phpinfo(); ?> 

    then save the file.

  9. Test the server with the browser and type address http://[server-ip]/info.php

That’s it for now. Thank you for visiting my blog. I hope you enjoy. Have a nice day…


  1. Pollo says:


  2. turionX2 says:

    nice post, thanks

  3. Account Dinko says:


  4. Redton says:

    Thanks for your help!

  5. xworld says:

    very good!thank you!

  6. shahryar says:
  7. FC says:

    I tried to install ubuntu-8.04.4-server-amd64. I have problem with perl.
    When I run my php script which contain perl, there is error : "Fatal error: Class 'Perl' not found in …………….."
    I have installed this : libapache2-mod-perl2 , perl-base , perl-modules
    I check in php -m , cannot find perl
    What should I do ? Thanks in advanced.

    BTW, do you come from country code .id ? 🙂

  8. Sg 1000 says:

    Login/Register script using PHP and MySQL
    The following example expalins the creation of simple login and registration page using PHP and MySQL.

  9. Elruinnou says:

    mantap nih om, keep posting, tengkyu om. 🙂

  10. Igor says:

    Thank you, Ivan, for this good and simple post for Linux newbie (and Win oldfag).

  11. Afsdaf says:

    Good job!
    I have been search it for a long time so you've helped me!
    Thanks a lot!

  12. Akyriacou84 says:

    thank sir! will be my first touch on linux ub10

  13. J-J Rikly says:

    Thanks, it's works well

  14. para acceder a http://localhost/phpmyadmin/
    se debe ejecutar:
    sudo ln -s /usr/share/phpmyadmin /var/www/

    fuente: http://www.guia-ubuntu.org/index.php?title=PhpMyAdmin

  15. Utn says:

    So what about mysqli

  16. Mailme Suryakant says:

    Hi Ivan,
    I am php deverloper from india. I like your article. It is greate helps me.
    I am facing one problem Please help me.
    I want to run mysql queries on ubuntu 10.10 terminal.
    i had given following commands but can't works

    root@arreys-24:/etc/init.d# cd mysql
    bash: cd: mysql: No such file or directory
    root@arreys-24:/etc/init.d# mysql start
    The program 'mysql' can be found in the following packages:
    * mysql-client-5.0
    * mysql-client-5.1
    Try: apt-get install <selected package>
    bash: mysql: command not found
    root@arreys-24:/etc/init.d# apt-get install mysql
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Couldn't find package mysql
    root@arreys-24:/etc/init.d# cd ..
    root@arreys-24:/etc# cd..
    bash: cd..: command not found
    root@arreys-24:/etc# cd ..
    root@arreys-24:/# /etc/init.d/mysql start
    bash: /etc/init.d/mysql: No such file or directory

    Please help me.

    • try find mysql with:
      apt-cache search mysql
      then find the correct name. and install it.

      use tab when writing your command, so after you write 3 char and tab to auto completion.

    • Surya says:

      Hey Ivan,
      Thanks. Actually i am new on ubuntu 10.10 Operating system.
      Great helpful for me and it is working.

      Once again thank you so much.

  17. Sunil bn says:

    Superb information….really learnt a lot…

  18. Rodrigofariat says:

    Hello !
    In /var/html the php is good.
    But in my home directory the php is fail
    I like to create phps in my home.

  19. Johanna says:

    THanks a lot it works. Now I have to figure out how to install perl and postgresSQL and to be able to view it on the browsor. Any suggestions?

  20. random says:

    Just a question:
    When you do apt-get install mysql-server, which version is the installation?

  21. Deepak Rao says:

    very helpful…thank you 🙂

  22. Kadela-erep says:

    thanks for your instruction 🙂

  23. Echobadut says:

    pake ubuntu 10.10
    $ su ganti pake $ sudo baru bisa jalan..
    maksih mas

    U great work

  24. ds says:


  25. selvamgowri.s says:

    etc/init.d/apache2 restart * Restarting web server apache2 (13)Permission denied: make_sock: could not bind to address no listening sockets available, shutting down Unable to open logs Action 'start' failed. The Apache error log may have more information. [fail]

    hi ivan

    i am getting the above things when i restart my apache

    how to get rid of it?????????????/

Give me your feedback

This site uses Akismet to reduce spam. Learn how your comment data is processed.