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:

rpm --import

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

rpm -ivh rpmforge-release-0.5.3-1.el6.rf.i686.rpm

for 64bit:

rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

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

rpm --import

for 32bit:

rpm -ivh

for 64bit:

rpm -ivh


rpm --import
rpm -ivh

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

yum install yum-priorities


vi /etc/yum.repos.d/epel.repo

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

Do the same for REMI repo:

vi /etc/yum.repos.d/remi.repo

2. Installation of MySQL 5

Install MySQL 5 with:

yum install mysql mysql-server

Then we need to add it to the services:

chkconfig --levels 235 mysqld on

Start the service:

service mysqld start

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


Install Apache with:

yum install httpd httpd-tools

Add it to services

chkconfig --levels 235 httpd on

Start the service:

service httpd start

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:

yum install php php-fpm mod_fastcgi

Add PHP-FPM to services:

chkconfig --levels 235 php-fpm on

Start the service:

service php-fpm start

Restart Apache:

service httpd restart

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

vi /etc/httpd/conf.d/fastcgi.conf

Add this to the end of the file:

DirectoryIndex index.html index.shtml index.cgi index.php
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host -pass-header Authorization

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:

mkdir /usr/lib/cgi-bin/

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

vi /etc/httpd/conf.d/php.conf

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

#PHP is an HTML-embedded scripting language which attempts to make it easy for developers to write dynamically generated webpages.
LoadModule php5_module modules/
LoadModule php5_module modules/
#Cause the PHP interpreter to handle files with a .php extension.
#AddHandler php5-script .php
#AddType text/html .php
#Add index.php to the list of files that will be served as directory indexes.
DirectoryIndex index.php
#Uncomment the following line to allow PHP to pretty-print .phps files as PHP source code:
#AddType application/x-httpd-php-source .phps

Save the file and restart Apache:

service httpd restart

6. Install MySQL support for PHP

Install PHP packages and php-mysql for MySQL support:

yum install php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc

Restart PHP-FPM to pickup the new components:

service php-fpm restart

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”:
    vi /etc/my.cnf
  2. Clean it (delete everything that is inside).
  3. Paste my configuration:
    default-storage-engine = myisam
    key_buffer = 1M
    query_cache_size = 1M
    query_cache_limit = 128k
    tmp_table_size = 1M
    max_heap_table_size = 1M
    max_allowed_packet = 1M
    sort_buffer_size = 64K
    read_buffer_size = 256K
    read_rnd_buffer_size = 256K
    net_buffer_length = 2K
    thread_stack = 64K
  4. Save the file
  5. Start MySQL:
    service mysqld start

Tunning FPM:



listen =


listen = /tmp/php5-fpm.sock
listen.owner = apache = apache




FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host -pass-header Authorization


FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /tmp/php5-fpm.sock -pass-header Authorization

Harris Marfel

Welcome to Harris Marfel (hrace009) Personal Blog. At this blog i only write what i like. If you don't like it, simple GTFO

Leave a Reply

Related Posts


[WordPress] Memperbaiki Error Sorry This File Type Is Not Permitted For Security Reasons

Jika website WordPress Anda mengalami error ketika mengupload file dengan pesan “Sorry, this file type is not permitted for security reasons”, tutorial kami kali ini dapat membantu Anda mengatasi masalah tersebut. Error tersebut merupakan salah Read more…


10 Best Free WordPress Gaming Themes 2017

Most of us have grown up playing video games. But the increasing fondness amongst adults for video games and online gaming, clearly hints that video games are not a kids domain any more. Many adults Read more…


Telkomsel terkena deface

Telkomsel adalah sebuah perusahaan telekomunikasi yang sangat besar di Indonesia, dan sekaligus menjadi layanan provider Internet yang jaringan nya sudah ada sekitar 90% di seluruh Indonesia. Namun sangat di sayangkan, mereka mematok harga yang sangat Read more…

%d bloggers like this: