In this tutorial we will cover the steps needed to install the LAMP stack on your CentOS 6.4, Debian or Ubuntu platform. LAMP is a combination of operating system and open-source software which will help you set up a working hosting environment. The acronym LAMP is derived from the first letters of Linux, Apache, MySQL and PHP.

Requirements:

  • CentOS 6.4, Debian or Ubuntu installed on your computer/server
  • SSH access (Command line access to the server)
  • root privileges
  • Basic skills for working on a Linux environment

Install Apache

We will begin with the installation of the Apache web server which is the most popular HTTP server these days. In order to install the Apache service we will use the default package manager included inside the corresponding Linux distribution:

CentOS 6.4

Ubuntu/Debian

You will be prompted to accept the installation and addition package dependencies will be displayed.

Test the functionality of the Apache service

Once the installation is completed you can test the Apache service using your browser:

or

where X.X.X.X is your server's IP address, i.e. http://1.2.3.4/

You should be able to see the default Apache page inside your browser.

An easy way to find your server's IP address is to execute the following command:

Install MySQL

MySQL is one of the most popular database management systems. The installation of the software can be completed with the following commands:

CentOS 6.4

Ubuntu/Debian

During the installation you might be prompted to set root password for the MySQL service. If not, you can set the root password after completion of the installation using the following command:

Test the functionality of the MySQL service

You can check if everything went well during the installation using the default MySQL client:

You will be prompted to enter the root password.

Install PHP

PHP is one of the most used open-source scripting languages preferred by the web developers. The software installation can be completed with the following commands:

CentOS 6.4

Ubuntu/Debian

Test the functionality of the PHP parser

Once completed you can test the functionality of the service by creating a test PHP info file inside the Apache web root folder (usually this is /var/www/):

containing the following lines:

Save the file and open it using your browser:

Default PHP information page should be displayed on your end.

Start Up Apache/MySQL automatically on server boot

In order for the services to start automatically upon server boot up you can execute the following commands:

CentOS 6.4

Ubuntu/Debian:

At the end you should have a working hosting environment which includes the Apache, MySQL and PHP software.