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.

Apache

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

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

MySQL

Installing MySQL is similar to installing Apache, except we have an additional step of running a basic setup wizard. When prompted by mysql_secure_installation, I recommend removing anonymous users, disallowing remote root logins, removing the test database and then reloading the privilege tables when prompted.

# yum install mysql-server
#chkconfig –add mysqld
#service mysqld restart
# mysql_secure_installation

PHP

Lastly, we install PHP and the PHP modules for MySQL. To install PHP 5.3 (new in CentOS 5.6), use the following:

# yum install php php-mysql

That’s it, you now have a LAMP ready CentOS server.