Jun 292016

When your webserver is receiving a lot of traffic and began slow your website down, you might be consider to switch mod_php with php-fpm.

  • First get mod_fastcgi from rpmforge
# yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
# yum install mod_fastcgi
  • Install php-fpm
# yum install php-fpm
  • Configure php-fpm
# vi /etc/php-fpm.d/www.conf
listen = /var/run/php5-fpm.sock
;listen =
listen.backlog = 1024
listen.owner = apache
listen.group = apache
listen.mode = 0666

user = apache
group = apache

pm = ondemand
pm.max_children = 75
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.process_idle_timeout = 10s
pm.max_requests = 500
  • Rename mod.php to mod.php.bak
# cd /etc/httpd/conf.d/
# mv php.conf php.conf.bak

that will disabled mod_php.

  • Configure mod_fastcgi in /etc/httpd/conf.d/fastcgi.conf. add these lines at the end of file.
# vi /etc/httpd/conf.d/fastcgi.conf
FastCgiWrapper Off
FastCgiConfig -idle-timeout 20 -maxClassProcesses 1
DirectoryIndex index.php
AddHandler php-fcgi .php
Action php-fcgi /php-fcgi
Alias /php-fcgi /cgi-bin-php.fcgi
FastCgiExternalServer /cgi-bin-php.fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization
  • Start php-fpm and restart httpd service.
# service php-fpm start
# service httpd restart

that’s it.

Oct 152009

Php default behaviour is always re-compile our script everytime accessed by users/browsers. eaccelerator can increases the performance of PHP scripts by caching them in their compiled state, so that the overhead of compiling is almost completely eliminated. It also optimizes scripts to speed up their execution. eAccelerator typically reduces server load and increases the speed of your PHP code by 1-10 times.

memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

Here’s how to install eaccelerator extension

$ wget http://bart.eaccelerator.net/source/0.9.6/eaccelerator-0.9.6-rc1.tar.bz2
$ tar xjf eaccelerator-0.9.6-rc1.tar.bz2
$ cd eaccelerator-0.9.6-rc1
$ phpize
$ ./configure
$ make
$ sudo make install
$ cd /var/cache
$ sudo mkdir eaccelerator
$ sudo chown -R apache:apache eaccelerator

Continue reading »