Sunday 22 May 2011

How to Install NGINX, PHP with PHP-FPM, and MySQL on Centos 5.5


OK now let’s add PHP and MySQL Support. I assume we already got MySQL on our system. If you dont, you can find somewhere else about how to install MySQL.
Get latest PHP source and PHP-fpm patch somewhere and put it on /usr/local/src folder. Proceed :

yum install libc-client-devel curl-devel libmcrypt-devel libmhash-devel yum install libevent-devel
cd /usr/local/src
tar -zxvf php-5.2.16.tar.gz
gzip -cd php-5.2.16-fpm-0.5.14.diff.gz | patch -d php-5.2.16 -p1
cd php-5.2.16
nano konfig

Paste this configure option :

./configure --enable-fastcgi --enable-fpm --with-mcrypt --enable-bcmath --enable-calendar --enable-exif --with-mysql --with-libdir=lib64 --enable-ftp --enable-gd-native-ttf --enable-libxml --enable-magic-quotes --enable-mbstring --enable-soap
--enable-sockets --enable-zip --prefix=/usr --with-curl=/usr --with-curlwrappers --with-freetype-dir=/usr --with-gd --with-gettext --with-imap --with-imap-ssl=/usr --with-kerberos --with-jpeg-dir=/usr --with-libexpat-dir=/usr
--with-libxml-dir=/usr --with-mysqli --with-openssl=/usr --with-openssl-dir=/usr --with-pic --with-png-dir=/usr --with-pspell --with-ttf --with-xmlrpc --with-xpm-dir=/usr --with-xsl --with-zlib --with-zlib-dir=/usr
--enable-inline-optimization --with-bz2 --with-pdo-mysql=shared --with-pdo-sqlite=shared --with-sqlite=shared --enable-wddx --with-mhash --enable-sysvsem --enable-sysvshm --enable-mbregex

then chmod konfig to add executable permission and compile PHP :

chmod +x konfig
./konfig
make
make install
pecl install memcache
cp /usr/local/src/php-5.2.16/php.ini-dist /usr/lib/php.ini
mkdir /etc/php/
ln -s /usr/lib/php.ini /etc/php/
ln -s /usr/etc/php-fpm.conf /etc/php/

Give php-fpm.conf a little touch on the default configuration on the process user & group part :

nano /etc/php/php-fpm.conf

Uncomment these line :

nobody
nobody

Then edit nginx default site configuration on /etc/sites/default.conf

location ~ .php$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_index index.php;
include /usr/local/nginx/conf/fastcgi_params;
}
}

Now restart NGINX

No comments:

Post a Comment