Installing NGINX, MySQL, PHP-FPM & XCache on CentOS 5.3 HOWTO
This post is pretty technical; if you don't consider yourself a geek, you'll likely want to skip it.
Apache is the most popular web server in the world. That doesn't necessarily mean its the best for all tasks though.
NGINX ("Engine X") is another web server. NGINX has been gaining quite a bit of popularity recently as it seems to run more efficiently than Apache, enabling less powerful web servers to handle a larger number of requests. This higher efficiency has made NGINX very popular in the virtual private server (VPS) scene.
I have a few VPS I use for experimentation / pet projects, and recently decided to give NGINX a try. But why stop there with the experimentation? Why not install XCache & PHP-FPM as well?
NGINX
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarc...
yum install nginx
(The config file will be installed to /etc/nginx/nginx.conf - check it out, much cleaner than httpd.conf imho)
LIBEVENT UPDATE
Download from http://monkey.org/~provos/libevent/
cd /usr/local/src
wget http://monkey.org/~provos/libevent-1.4.13-stable.tar.gz
tar xzf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure --prefix=/usr
make
make install
libtool --finish /usr/lib
LIBXML
cd ..
wget ftp://xmlsoft.org/libxml2/libxml2-2.7.2.tar.gz
tar -xzf libxml2-2.7.2.tar.gz
cd libxml2-2.7.2
./configure --prefix=/usr
make
make install
MCRYPT
yum install mcrypt
yum install libmcrypt
yum install libmcrypt-devel
PHP-FPM
Download it here: http://php-fpm.org/download/
cd ..
wget http://ca3.php.net/get/php-5.3.2.tar.bz2/from/this/mirror
tar -jxvpf php-5.3.2.tar.bz2
wget http://github.com/dreamcat4/php-fpm/tarball/0.6-5.3.1
gunzip dreamcat4-php-fpm-3bb2b9b.tar.gz
tar xvf dreamcat4-php-fpm-3bb2b9b.tar
dreamcat4-php-fpm-3bb2b9b/generate-fpm-patch
cd php-5.3.2
patch -p1 < ../fpm.patch
./buildconf --force
mkdir fpm-build && cd fpm-build
../configure --with-fpm --with-libevent=shared,/usr/lib --with-mcrypt --with-zlib --enable-mbstring --with-openssl --with-mysql --with-mysql-sock --with-gd --with-jpeg-dir=/usr/lib --enable-gd-native-ttf --without-sqlite --disable-pdo --disable-reflection --with-libxml-dir=/usr/lib --with-mysqli=/usr/bin/mysql_config --with-curl --prefix=/usr/local/php --with-config-file-scan-dir=/etc/php.d --with-fpm-user=nginx --with-fpm-group=nginx
make
make install
cp php.ini.production /usr/local/php/lib/php.ini
XCACHE
Download the newest version of XCACHE from http://xcache.lighttpd.net/wiki/ReleaseArchive
cd ..
wget http://xcache.lighttpd.net/pub/Releases/1.3.0/xcache-1.3.0.tar.gz
tar xvf xcache-1.3.0.tar.gz
cd xcache-1.3.0
/usr/local/php/bin/phpize
./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
make
make install
cp xcache.ini /etc/php.d/xcache.ini
vi xcache.ini
comment out any lines which say "zend_extension", and instead place this line:
zend_extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/xcache.so
Set to run automatically on startup:
ntsysv
select "nginx" and "php-fpm"
hit save.
And your done!
