How to install LAMP ( Linux, Apache, MySql and PHP/Python/Perl ) on Ubuntu Linux

Hello guys, welcome to DataHackr.com.  Today on “Teach Me How?” Section, I am going to show you how to configure LAMP ( Linux, Apache, MySql and PHP/Python/Perl ) on Linux operating systems.

Before I dive in to the details, let me tell you little about LAMP.

What is the LAMP stack?

LAMP stack is a popular open source web platform commonly used to run dynamic web sites and servers. It includes Linux, Apache, MySQL, and PHP/Python/Perl and is considered by many the platform of choice for development and deployment of high performance web applications which require a solid and reliable foundation.

Why LAMP?

Due to the nature of free and open-source software and the ubiquity of its components, each component of the LAMP stack is very well tested regarding performance and security. At the same time, there is an abundance of experienced contractors to do the tailoring required for various customizations, or for complex setups.

Lamp Installation for Linux Ubuntu:

To install the default LAMP stack in Ubuntu 10.04 and above

  1. First install tasksel:
user@ubuntu :~$ sudo apt-get install tasksel

Note: If you get an error message something like the following.

user@ubuntu:~$ sudo dpkg --configure -ad
pkg: error: dpkg status database is locked by another process

Run the bellow commands first, and then repeat from the beginning.

user@ubuntu :~$ sudo rm /var/lib/dpkg/lock
user@ubuntu :~$ sudo dpkg --configure -a
  1. Now Install the LAMP stack:
user@ubuntu :~$  sudo tasksel install lamp-server

During the Installation of MySQL from the LAMP package, the setup will prompt you to set a Password for the MySQL Access.
2
This password is Used to access the MySQL Database:

$ mysql –u root –p
  1. Now that you have finished the Installation, you need to test if all the features are working properly (PHP, Apache, and MySQL). Follow the bellow steps to test these features.

  2. Checking Apache installation:
    With your web browser, go to the URI http://localhost : if you read “It works!”, which is the content of the file /var/www/index.html , this proves Apache is working.
    4

  3. Checking PHP installation:
    In /var/www , create a text file called “test.php”, grant the permission (everyone or, at least, Ubuntu user “apache”) to modify it, write in it the only line: “” (without the quotation marks) then, with your web browser, go to the URI “http://localhost/test.php“: if you can see a description of PHP configuration, it proves PHP works with Apache.
    5

  4. Checking MySQL Installation:
    Try logging into mysql database using the password created during the installation process.

$ mysql –u root –p
$Enter-Password:*******

If the login is successful, and the MySQL prompt is returned. Then the MySQL is working with Apache.

This completes the installation of LAMP Server for Linux (Ubuntu). Please leave your comments below if you need any further assistance.

Also don’t forget to like us on LinkedIn @DataHackr

Please Like, Share and Tweet
Team DataHackr

Scroll to Top