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.

<?php
   echo ' It works on PHP too ' ;
?>

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

Uncategorised

Leave a Reply

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