Install PHP, MySQL and Apache (LAMP) on Ubuntu (Linux)

If you are new to Ubuntu, and want to install PHP, MySQL and Apache, simply goto the Terminal (gnome-terminal) through:

Applications -> Accessories -> Terminal

and write the following commands:

1. Apache HTTP Server:

sudo apt-get install apache2

To start the Apache server, you have to write:
sudo /etc/init.d/apache2 start

To stop the Apache server, write:
sudo /etc/init.d/apache2 stop

To restart, write:
sudo /etc/init.d/apache2 restart

2. PHP 5:

sudo apt-get install php5 libapache2-mod-php5

3. MySQL Server:

sudo apt-get install mysql-server

After these installations, restart the Apache server by typing:
sudo /etc/init.d/apache2 restart

After successful installation of the above mentioned steps, simply write http://localhost/ on your browser, and see if you see the text: It works

Now goto the folder where you have to place your other PHP projects or files i.e. /var/www and change the index.html file to index.php, and by editing it, write some PHP code in it to check if PHP also works in it e.g.

   echo ' It works on PHP too ' ;

Simple isnt it? Now start working on your different projects with PHP and MySQL on Ubuntu.

  1. Hi,

    I could not alter the index.html file in the /var/www directory for php support as I haven’t got a superuser
    In fact I don’t even recall being prompted for a root user password during the Ubuntu 11.04 installation
    When I go through the Ubuntu Software Center, I can install and remove programs by providing my userid
    password but of course, at the bash shell prompt, if I need to be root user my regular userid password is not
    This is my own personal computer at home on which I setup Ubuntu myself.
    I am the single user of my computer I am totally without access to su commands.

    I have no idea how to fix this problem.
    I hesitate to reinstall since I have 550 programs installed many of which have associated data.

    Any help would be appreciated.



Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>