Atlantic.Net Blog

How to Install a LAMP (Apache, MySQL, PHP) stack on CentOS 6.7

Jose Velazquez
by Atlantic.Net (71posts) under Cloud Hosting
LAMP Magic In Your Hands created by Walker Cahall

LAMP Magic In Your Hands created by Walker Cahall

Verified and Tested 08/12/15


In this How-To, we will walk you through the installation of a LAMP stack on a CentOS 6.7 based server. Although we are writing this article in the context of CentOS 6.7, a Linux, Apache, Mysql, PHP(LAMP) server is a common installation stack capable of being hosted on many different Operating Systems. Examples of such are Debian (see our how-to on this here) and Debian based distributions like Ubuntu (see our how-to for Ubuntu here), or RHEL and RHEL based distributions such as Fedora or Scientific Linux. You’ll see these installations occurring on a variety of hosting platforms such as shared web hosting, dedicated hosting and cloud hosting.

In the case of this article, we’ll be utilizing the YUM package manager associated with the RHEL distribution CentOS.


A server with CentOS 6.7  installed will take care of the Linux aspect of the LAMP stack install. If you do not have a server, consider a reliable SSD cloud hosting server from Atlantic.Net.

Installing Apache on CentOS 6.7

Install Apache with the following command to begin the install:

sudo yum install httpd

Start Apache with the following command:

sudo service httpd start

We can now verify Apache is working by opening your browser and entering the URL http://your-server's-address. you should get a blue Apache 2 test page similar to the image below.

Note: If you do not know your IP address, run the following command:

ip addr show eth0
An example of running the command: ip addr show eth0 and getting for the IP address.

An example of running the command: ip addr show eth0 and getting for the IP address.

In our example we would put into our browser’s address bar.


Apache 2 Test page

Apache 2 Test page

Installing MySQL on CentOS 6.7

Install MySQL with the following command to begin the install:

sudo yum install mysql-server

Start the service with the following command

sudo service mysqld start

Set root MySQL password with the following command:


Note: You will be prompted with a series of questions. Simply type Y for yes on all of them, see the screen shot below:

Sample mysql_secure_installation

Sample mysql_secure_installation

Installing PHP on CentOS 6.7

Install PHP with the following command to begin the install:

sudo yum install php php-mysql

Create a test PHP file in the following directory with the following command:

sudo vi /var/www/html/info.php

Insert the following code in the empty space then save and exit:


Restart apache so all the changes take effect:

sudo service httpd restart

Test your page in your browser with the following hyperlink changed with your IP address:

Sample info.php

Sample info.php

It is a good idea to remove your file as it can be used to aid an attacker to compromise your server. You can do that with the following command:

sudo rm /var/www/html/info.php

If you would like Apache and MySQL to start on boot, run the following commands:

sudo chkconfig httpd on
sudo chkconfig mysqld on

Congratulations! You have just installed a LAMP stack on your CentOS 6.7 Server. Thank you for following along in this How-To and check back with us for any new updates, or to learn more about our industry leading cloud hosting solutions.

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G2.1GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year

New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4


London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom


We use cookies for advertising, social media and analytics purposes. Read about how we use cookies in our updated Privacy Policy. If you continue to use this site, you consent to our use of cookies and our Privacy Policy.