Build a LAMP stack (Linux, Apache, MySQL, PHP) - CentOS 6

Difficulty: 3
Time: 20 minutes

To build a dynamic web application, you need what has been coined a “stack” - which is developer lingo for an integrated set of software that has all of the components your application needs.

Most stacks have the same types of components and differ mainly in which pieces of software they use for those components. For example, we’ll look at LAMP (which this article covers):

Component LAMP Software
Operating system Linux (e.g. CentOS)
Web server Apache
Database MySQL
Programming language PHP

If you're astute, maybe you noticed that LAMP is just an acronym for the software the stack uses.

In this guide, we'll walk you through installing all of these components (except for Linux, which is already installed as your OS when you create the server).

Install Apache

  1. Before you begin any installation, make sure that your software is up to date:
    sudo yum update
  2. Install Apache:
    sudo yum install httpd
  3. Start Apache:
    sudo service httpd start
  4. Set Apache to start on server boot:
    sudo chkconfig httpd on
  5. Verify that Apache is installed by going to:
    http://your server's IP address.
    If Apache is installed, the Apache Test Page displays.

    Note: GoDaddy Cloud Server customers can use Find your server's IP.

Install MySQL

  1. Install MySQL:
    sudo yum install mysql mysql-server
  2. After the installation is complete, start the service:
    sudo service mysqld start
  3. Set MySQL to start on server boot:
    sudo chkconfig mysqld on
  4. Run this command to finish setting up the installation:
    sudo /usr/bin/mysql_secure_installation
  5. You will be asked for the root password. Because you didn't set it earlier, press Enter to set a password now.
  6. Type "Y" to set the root password.
  7. Enter and confirm the new password.
  8. You will be asked more questions as part of security configuration. It is a best practice to respond "Y" to these system prompts.

Install PHP

  1. Install PHP
    sudo yum install php php-mysql
  2. Enter "Y" to install.
  3. Restart Apache:
    sudo service httpd restart

Install PHP modules

If your applications requires any PHP modules, you can install them now.

  1. View available PHP modules:
    yum search php-
  2. The list displays the available PHP modules. If you want to get more information on a specific package, you can display the description by typing:
    yum info name of package you want to install
  3. Install the package you want:
    sudo yum install the name of the package you want to use

Test PHP processing on Apache

  1. Create a new PHP file under the /var/www/html directory:
    sudo vim /var/www/html/info.php
  2. When the file opens, type in the following code:
  3. Save and close the file:
  4. To verify that it works, type this URL in your browser:
    http://your server's IP address/info.php

A page displays with the PHP version, extensions, build date, and other information.

Next steps

Now that you have a LAMP stack, we recommend setting up Apache Virtual Hosts for your websites:

Помогла ли вам эта статья?
Благодарим вас за отзыв. Чтобы связаться с сотрудником службы поддержки клиентов, позвоните по номеру этой службы или воспользуйтесь опцией чата выше.
Мы рады вам помочь! У вас остались вопросы?
Приносим извинения. Расскажите нам, какие затруднения вы испытываете или почему рекомендованное решение не помогло устранить проблему.