LAMP on CentOS 6

Install Apache Web

sudo yum install httpd

Edit Apache's httpd.conf

The httpd.conf can be found in /etc/httpd/conf/ and configures resource usage.

This is an example of a configuration for a VPS with 2GB of RAM:

KeepAlive Off
<IfModule prefork.c>
MinSpareServers 20
MaxSpareServers 40
MaxClients 200
MaxRequestsPerChild 4500

NOTE: The Apache config should be closely monitored. Different sites may require adjustment of these values to optimize performance. This configuration is presented as a good baseline.

Set Up Virtual Hosts

Create a file named vhost.conf in /etc/httpd/conf.d using your own domain in place of

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/
ErrorLog /var/www/
CustomLog /var/www/ combined

NOTE: you will need to make a new entry in your vhost.conf file like this for each domain you intend to host on your VPS

Now you must make the directories referenced in your vhost.conf file - remember to replace with your actual domain name:

sudo mkdir -p /var/www/
sudo mkdir /var/www/

Start Apache

The first command will start the Apache service, and the second command will make Apache run on boot:

sudo service httpd start
sudo /sbin/chkconfig --levels 235 httpd on

Install MySQL

sudo yum install mysql-server

Start MySQL

sudo service mysqld start
sudo /sbin/chkconfig --levels 235 mysqld on

Secure MySQL

We suggest you answer "yes" to all the options given when you run this command:


Create a Database

First you will need to log in to MySQL:

mysql -u root -p

Now, create a database and user, replacing webdata with your database name, webuser with your username, and password with a strong password:

create database webdata;
grant all on webdata.* to 'webuser' identified by 'password';

Quit MySQL:


Install PHP

sudo yum install php php-pear

Install MySQL support:

sudo yum install php-mysql

Edit the /etc/php.ini to improve performance, error messages, and logs:

error_log = /var/log/php/error.log
max_input_time = 30

Create the error directory

sudo mkdir /var/log/php
sudo chown apache /var/log/php

Restart Apache:

sudo service httpd restart


  • 13 Users Found This Useful
Was this answer helpful?

Related Articles

IP rDNS/PTR records

You can configure PTR or Reverse DNS records via the VPS Control Panel under rDNS. The record...

Serial Console

You may wish to use the Serial Console if the SSH console becomes inaccessible. The Serial...

LAMP on Debian 7

Install Apache Web sudo apt-get install apache2 Edit Apache's httpd.confThe...

LAMP on Ubuntu 14.04

Install Apache sudo apt-get update sudo apt-get install apache2 Install MySQL...

WordPress on Ubuntu 14.04

NOTE: You must have the LAMP stack installed before installing WordPress.Create the WordPress...