How to Build LAMP Server on CentOS 6.4
| |I’ve explained how to build a LAMP server (Linux, Apache, MySQL, PHP) on CentOS but this page will focus mainly on CentOS 6.4. The whole steps are basically similar but I will show it again in shorter way assuming you knew some basic skills already. So read on!
Some FYIs:
- This example use CentOS 6.4 x32 VPS hosted by DigitalOcean. This VPS has 512MB of RAM.
- Proceed with caution
- You better read: Basic CentOS Setup Before Building A Working Server
How to Install Apache, MySQL, PHP on CentOS 6.4 Server
Step 1 – Add Remi repository (optional but you better do this):
The command syntax for CentOS 6.4 on 32bit server:
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
The command syntax for CentOS 6.4 on 64bit server:
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
Step 2 – It’s time to use the magic spell: a single command syntax to install Apache, MySQL5 and PHP5 on CentOS 6.4:
yum --enablerepo=remi,remi-test install httpd mysql mysql-server php php-common
Step 3 – Install some necessary PHP modules (I’ve explained it already in most of my tutorials). Use this command to check all available modules:
yum search php
In my example I will install:
- MySQL (php-mysql) – A extension for PHP applications that use MySQL databases.
- PostgreSQL (php-pgsql) – A extension for PostgreSQL database for PHP.
- MongoDB (php-pecl-mongo) – A driver for MongoDB database.
- SQLite (php-sqlite) – Extension for SQLite Database Engine.
- Memcache (php-pecl-memcache) – Memcached caching daemon.
- Memcached (php-pecl-memcached) – Memcached caching daemon.
- GD (php-gd) – GD extension for PHP application to serve graphics.
- XML (php-xml) – XML Parser for PHP applications.
- MBString (php-mbstring) – Mbstring extension is used to handle multi-byte string in PHP applications.
- MCrypt (php-mcrypt) – A Mcrypt library for PHP scripts.
- APC (php-pecl-apc) – APC module used to optimize and cache PHP code.
- CLI (php-cli) – Command-line interface for PHP.
- PEAR (php-pear) – Application Repository framework for PHP.
- PDO (php-pdo) – Database access module for PHP applications.
So the final command syntax looks like this:
yum --enablerepo=remi,remi-test install php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml php-pecl-apc php-cli php-pear php-pdo
Step 4 – You have to also configure your system to start Apache and MySQL service at boot time:
chkconfig --levels 235 httpd on chkconfig --levels 235 mysqld on
Step 5 – Fire up Apache (start it to run at the very first time):
/etc/init.d/httpd start
Step 6 – Also start MySQL service:
/etc/init.d/mysqld start
That’s it. Catch all tutorials about CentOS here.
Further reading:
Oh~It is very detail, I love your post.
A php module was failing, so I installed them one by one. php-pecl-memcached was giving an error. So I had to do this:
yum –enablerepo=remi,remi-php54 install php-pecl-memcached
instead of:
yum –enablerepo=remi,remi-test install php-pecl-memcached
I’m guessing if you have php55 you’ll need to change this to that?