Tag Archives: php

memcache on CentOS

yum install memcached php-pecl-memcache
pecl install memcache

if pecl fail you can install from source:
wget http://pecl.php.net/get/memcache
tar xvfz memcache-*
cd memcache*
phpize
./configure
make && make install
echo extension=memcache.so >> /etc/php.ini

service httpd restart
service memcached start
or maybe run manually:
memcached -d -m 512 -l 127.0.0.1 -p 11211 -u nobody

mod_fastcgi vs mod_fcgid

Apache can be configured to run FastCGI with two modules: mod_fastcgi and mod_fcgid. The difference is that mod_fcgid passes just one request to the FCGI server at a time while mod_fastcgi passes several requests at once, the latter is usually better for PHP, as PHP can manage several request using several threads and opcode caches like APC usually work only with threads and not with processes. This means that using mod_fcgid you end up having many PHP processes which all have their very own opcode cache.”

mod_fastcgi with PHP-FPM on Centos

yum install php-fpm
chkconfig –levels 235 php-fpm on
vi /etc/php-fpm.d/www.conf
;listen = 127.0.0.1:9000
listen = /tmp/php5-fpm.sock
pm.status_path = /status
ping.path = /ping

service php-fpm start

yum install http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
yum install mod_fastcgi # Get mod_fastcgi from rpmforge or compile yourself

yum install libtool httpd-devel apr-devel apr
wget http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz
tar -zxvf mod_fastcgi-current.tar.gz
cd mod_fastcgi*
make top_dir=/usr/lib64/httpd
make install top_dir=/usr/lib64/httpd

mv /etc/httpd/conf.d/{php.conf,php.conf.disable}
mkdir /usr/lib/cgi-bin/
vi /etc/httpd/conf.d/mod_fastcgi.conf
LoadModule fastcgi_module modules/mod_fastcgi.so


DirectoryIndex index.php index.html index.shtml index.cgi
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 -socket /tmp/php5-fpm.sock -pass-header Authorization

# For monitoring status with e.g. Munin

SetHandler php5-fcgi-virt
Action php5-fcgi-virt /php5-fcgi virtual

service httpd restart