Installing the LAMP Stack (Linux, Apache, MySQL and PHP) on CentOS

Posted on August 12, 2015 How-To Guides

What is LAMP?

Besides a wonderful device that produces light, LAMP stands for Linux, Apache, MySQL and PHP.

It’s a common combination of services that are needed in web development when setting up a server.

When you activate a cloud server with NETdepot you’ll more than likely want this combo installed to start development.

Step 1: Getting Set Up

First things first, you need a program that will allow you to talk to your server. There are two main options for this depending on what OS you’re running.

On a PC, follow these steps to start talking to your server:

  1. Install and launch Putty.
  2. Enter in your server details, then click Open
  3. Not sure what your IP is? Log in to your Control Panel and view the details of the server you would like.
  4. You may get a message about the “server’s host key”. Just click “Yes” to continue.
  5. Follow the prompts to enter your username and password.
  6. Do a dance, you’re in.

On a Mac, follow these steps to start talking to your server:

  1. Launch Terminal
  2. Go to Shell > New Remote Connection…
  3. In the bottom of the window, type ssh root@YOUR_IP_ADDRESS
  4. Not sure what your IP is? Log in to your Control Panel and view the details of the server you would like.
  5. You may get a message about the “authenticity of host”. Type “yes” and hit Return.
  6. Now, enter your password found on the same page your IP address was and hit Return.
  7. Do a dance, you’re in.

Step 2: Installing Apache

As cool as it would be to install an army-grade helicopter or tomahawk wielding indian into your server, we’re actually going to install an open source web server that runs on your Linux OS.

This allows you to actually host a website on your server.

Head over to your terminal we just launched and type this command:

sudo yum install httpd

You should see the download processing before it asks you if you want to install:

Type “y” and hit Enter.

Once you see that it has completed, start your Apache server by typing:

sudo service httpd start

Apache should be installed properly now. To check it, navigate to your IP address in the address bar of your browser. You should see some form of a test page letting you know that Apache has installed properly.

Step 3: Installing MySQL

MySQL is an open source database management system often used to store user data on a web server.

With your terminal still open, type in the following command:

sudo yum install mysql-server

If you are running CentOS 7+, then you’ll need to install MySQL using the following commands:

yum install http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
yum install mysql-community-server

Once MySQL is installed, start the service using:

sudo service mysqld start

Next you’ll need to set up a root password:

sudo /usr/bin/mysql_secure_installation

When asked for your current root password, leave the field blank and hit Enter.

Type “y” and hit Enter again when it asks if you would like to set the root password.

Set the password and be sure to store the password somewhere so you can use it when installing a CMS like WordPress or building your custom database.

Next you will be asked a series of questions. Read through them and determine what you want your answers to be, but more than likely you’ll be hitting “y” on your keyboard a lot.

Step 4: Installing PHP

PHP is a server-side scripting language designed for web development.

Terminal still open? Good. Type:

sudo yum install php php-mysql

Then follow the prompts to install PHP.

Just like that, you’re done.

Other Notes

Module Installation

PHP has a few modules that can or may need to be installed depending on your project specs. To view the list of modules type:

yum search php-

From there if you want to install one of the modules type:

sudo yum install <INSERT MODULE NAME>

Need more information on our cloud servers or any of our other products? Contact us online or call 844-25-CLOUD.

Contact Us Today To Experience How We Can Save You Time, Money And Stress