Setting up Apache, PHP and MySQL in Ubuntu

To set up Apache, PHP and MySQL, all you have to do is run a few commands in the terminal. Given below is the brief instruction set for the same.

Installing Apache2:

Run the following commands in your Ubuntu terminal.

  1. sudo apt-get install apache2
  2. sudo /etc/init.d/apache2 restart

Now that you have installed and restarted apache2, check if it is working in your local machine.

For this type

http:// localhost

in your web browser. If you read “It works”, it proves that apache is working.

Installing PHP5:

Run the following commands on your Ubuntu terminal.

  1. sudo apt-get install libapache2-mod-php5
  2. sudo a2enmod php5

To check if your php is working, create a file one.php in var/www folder and try if it can be written. Otherwise, you can use the following commands:

  1. cd /var
  2. sudo chmod -R 777 www

This will set write permission for files in www.

Installing MySQL:

Run the command:

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

To access the mysql console, you have to type:

mysql -u root

and if you have an already set password then the command will change as:

mysql -u root -p

To set up phpmyadmin:
run the command:
sudo apt-get install phpmyadmin
Go to your browser, type in localhost/phpmyadmin.
If this doesn’t show up the phpmyadmin page, got var/www and see if the phpmyadmin folder is there. Else, goto usr->share and copy the phpmyadmin folder to var/www
Now localhost/phpmyadmin should work.

These are the very basic steps of installation explained above.

Hope this post made installation a bit easy for you.

One Reply to “Setting up Apache, PHP and MySQL in Ubuntu”

Leave a Reply

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