Cuelogic Blog Icon
Cuelogic Career Icon
Home > Blog > All > Installing Apache, MySQL, PHP and phpMyAdmin on Ubuntu 13.04

Installing Apache, MySQL, PHP and phpMyAdmin on Ubuntu 13.04

Installing LAMP on ubuntu is much easier, just few useful commands and your LAMP stack is up and running

Let’s get started..!!

sudo apt-get update
sudo apt-get upgrade


sudo apt-get install apache2


sudo apt-get install mysql-server mysql-client


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

Restart Apache

/etc/init.d/apache2 restart


sudo apt-get install phpmyadmin

Done !!  Your LAMP stack is up and running  :) 

Change default DocumentRoot /var/www

If you wish to change the default document root, follow the follwoing steps, currently the default document root is set to /var/www/ :

In order to change the default site location to a different one, /opt/mysite use the following method. A detailed steps to install LAMP on ubuntu is given here.

To do this, we must create a new site and then enable it in Apache2.

To create a new site:

Copy the default website as a starting point.

sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/mysite

Edit the new configuration file in a text editor

sudo nano /etc/apache2/sites-available/mysite

Change the DocumentRoot to point to the new location. For example, /opt/mysite (make sure there is no space in your new folder name; /opt/my\ site/ will not work)

Change DocumentRoot /var/www to DocumentRoot /opt/mysite

Change the Directory directive, replace <Directory /var/www/> to <Directory /opt/mysite/>

You can also set separate logs for each site. To do this, change the ErrorLog and CustomLog directives. This is optional, but handy if you have many sites

Save the file

Now, we must deactivate the old site, and activate our new one. Ubuntu provides two small utilities that take care of this: a2ensite (apache2enable site) and a2dissite (apache2disable site).

sudo a2dissite default && sudo a2ensite mysite

Finally, we restart Apache2:

sudo service apache2 restart