Install LAMP (Linux, Apache, MySQL, PHP) on CentOS 5.6

This article will outline the process for installing Linux, Apache, MySQL and PHP (also known as ‘LAMP’) on CentOS 5.6.

Getting Started

First of all, make sure your YUM repositories and packages are up to date:

# yum check-update
# yum update

Install any available package and library updates.


Next, install Apache, set it to run on startup, and finally start the service:

# yum install httpd
# chkconfig –add httpd
# service httpd start


Installing MySQL is similar to installing Apache, except we have an additional step of running a basic setup wizard.

Installing PHP 5.2.x on CentOS

At the time of writing, PHP 5.1.6 is the “current” version shipped with CentOS 5.4. While I’m sure there is valid (?) reason for CentOS still distributing 5.1, many web developers need 5.2 functionality in their applications to run correctly.

There are two common ways to upgrade CentOs 5.4 to PHP 5.2:

  1. Download, compile and install Apache and PHP from source.
  2. Use yum with the CentOS Testing Repository

Compiling From Source

If you want to install from source, the standard ./configure; make; make install process will work in most cases (actually, if you want to do anything productive, it will be a bit more complicated than this).

While this process affords you the ability to fine-tune your configuration, you loose automatic updates and any future modifications to the Apache or PHP configuration will most likely require recompilation.

Using yum

Since we’re using CentOS, the best approach is to just go with the native package manager. Like it or not, RPM is a solid package manager which really makes life easy if used correctly. Yum is the fronted for RPM management in CentOS.