How to install Ubuntu,Linux, Apache, MySQL, PHP (LAMP)

Sharing is caring!

Group of open source software’s (free software) called LAMP. The acronym stand for Linux, Apache, MySQL, and PHP. Normally this cluster is used for running web server. 

LAMP can be installed by three different way 

1st way: 

By opening terminal and typing following will install the LAMP

sudo apt-get install lamp-server

It will eventually reach to the point where you have to set password for My

2nd way:

By opening terminal and typing following will install the LAMP

sudo apt-get install tasksel

It is also possible to install LAMP with tasksel. Tasksel is installed by default on Ubuntu Server editions but not the Ubuntu Desktop edition


3rd way:

Install Ubuntu (Linux)
Down load Ubuntu from following website
Ubuntu have two flavour’s 32-bit and 64-bit, Choose appropriate one and burn a CD, Boot from that CD and follow the instruction.
If you are installing as VM just download and create new virtual machine, choose your OS and select downloaded Ubuntu ISO.
Note: To test you can install Free VM Player or virtual box and install any OS on your existing machine without losing your existing OS.  
Install Apache
To install apache you need to have root privileges on your machine or vm
Open Terminal (Terminal can be found by clicking on Dashboard icon and typing terminal in search bar)
Type in following command
sudo apt-get update
sudo apt-get install apache2
Note: APT is tool to add/remove (install/uninstall) software on the Linux distribution. Significant part of apt is c++ library functions like apt-get and apt-cache.
 /etc/apt has the apt configuration folders and files.
To check if apache is installed. Direct your browser to your server/machine ip address ( and page should come up, it works.
Note: You may need to run the following command to find your server ip address.
ifconfig eth0 | grep inet  or  ifconfig eth0 | fgrep inet

To be more specific you can use awk to extract exact information. 
ifconfig eth0 | grep inet  | awk ‘{print $2}’
Install MySQL
We will divide this part in three section. Installation, Activation and Securing
To install MySQL, open terminal and type following command
sudo apt-get install mysql-server
During the installation mysql will ask you to set a root password, please do so but if you miss, you can always set from after installation from MySQL shell.
Once you have installed, we should activate it by following command
sudo mysql_install_db
Secure the mysql by running following command, Following command will allow you to set a root password, if you have set already it can be reset, Disable anonymous user, delete test database and disallow remote login etc.
sudo /usr/bin/mysql_secure_installation
Install PHP
PHP is open source web scripting language. To install PHP open terminal and type following.
sudo apt-get install php5
Note: To add php to directory index use this command
sudo nano /etc/apache2/mods-enabled/dir.conf
Add index.php to the beginning of index files. The page should now look like this: 
DirectoryIndex index.php index.html index.cgi index.php index.xhtml index.htm
Add PHP libraries and modules.
apt-cache search php5-   
This will display list of available modules which can be installed by typing following command on terminal prompt.
sudo apt-get install
Restart apache by typing following command so that all of the changes take effect.
Sudo service apache2 restart
Test installation:
Lets write first php file, this can be done by opening up any editor like vi, nano etc.
Sudo nano /var/www/test.php       this will open up editor, please type in following lines
Save and Exit
Finish up by visiting your php info page (make sure you replace the example ip address with your correct one):

Leave a Reply

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