Apache + PHP-FPM + MySQL on CentOS 6.5

Posted on

At this tutorial/guide/HowTo I will teach you how to install Apache (2.x) with PHP5-FPM and MySQL on CentOS 6. This setup is also well-known as “LAMP” where L stands for Linux, A for Apache, P for PHP and M for MySQL. This tutorial/guide/HowTo might work on CentOS 6.5 (Already test), the rest of it, i don’t know :p

I’m not responsible for any kind of failures or damage!!!

1. Installation of additional repositories

We need to import the Dag GPG key:

Now we’ll install the rpmforge repo:
for 32bit:

for 64bit:

As PHP-FPM can’t be downloaded with the default CentOS repo we need the EPEL and the REMI repo:

for 32bit:

for 64bit:


After that we need to install a plugin for yum that manages repo priorities:


Add “priority=10” to the [epel] section and save the file

Do the same for REMI repo:

2. Installation of MySQL 5

Install MySQL 5 with:

Then we need to add it to the services:

Start the service:

Run the secure setup to set a root password and a few others things:

Install Apache with:

Add it to services

Start the service:

Apache’s default document root is /var/www/html for CentOS. The configuration file is /etc/httpd/conf/httpd.conf and additional configurations are saved in the /etc/httpd/conf.d/ directory.

3. Installation of PHP-FPM
Install PHP-FPM and mod_fastcgi:

Add PHP-FPM to services:

Start the service:

Restart Apache:

5. Configuration of Apache with PHP-FPM
Open the fastcgi.conf file:

Add this to the end of the file:

After that search after “FastCgiWrapper” and make sure it’s set to “off” then save the file.

The /usr/lib/cgi-bin/ directory must exist, so we create it:

If mod_php is installed and enabled, we need to disable it so open the configuration at /etc/httpd/conf.d/php.conf:

Comment out the AddHandler and AddType lines so it looks like here:

Save the file and restart Apache:

6. Install MySQL support for PHP

Install PHP packages and php-mysql for MySQL support:

Restart PHP-FPM to pickup the new components:

Now you should have a working web server with Apache, PHP-FPM and MySQL.


Is MySQL not starting up?

Edit “my.conf” the MySQL configuration file with a text editor and paste our configuration.

  1. Open “my.cnf”:
  2. Clean it (delete everything that is inside).
  3. Paste my configuration:
  4. Save the file
  5. Start MySQL:

Tunning FPM:






Harris Marfel (hrace009) - Memberikan informasi dan Tutorial yang bermanfaat untuk para pemula, dan semua tutorial yang disajikan kami berikan secara gratis!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.