Latest Stable Version Nginx 0.8.54 with PHP 5.3.5

by admin on February 13, 2011

in Http Maid Note

This is the improvement of my previous Nginx version 0.8.53 with PHP 5.3.5 installation, and also this time i’m not using php-fpm to run fastcgi, i’m using php-cli command to run fastcgi, and the result is memory usage decreased about 50MB. So let’s get it on!

VPS: CentOS 5.5 32bit with 256MB RAM XEN

Add EPEL and REMI repository, also update YUM (we will use REMI reposity for PHP 5.3.5)
EPEL 32bit

rpm -Uvh

EPEL 64bit

rpm -Uvh


rpm -Uvh
yum -y update

Install Nginx

yum -y install GeoIP GeoIP-devel GeoIP-data perl libperl


rpm -Uvh


rpm -Uvh

start Nginx and add to init

/etc/init.d/nginx start
chkconfig --add nginx
chkconfig nginx on

Configure Nginx virtual host
As usual i prefer separate Nginx vhost for each domain so it will be easier to manage, and “/home” directory for domain root so it will ease you to synchronize domain root with ftp user root

create your domain root

mkdir -p /home/domain/public_html
mkdir -p /home/domain/logs

create two directory for domain vhost

mkdir /etc/nginx/sites-available
mkdir /etc/nginx/sites-enabled

edit Nginx configuration

nano /etc/nginx/nginx.conf

add the following lines to your nginx.conf before the last “}” character and save

# Load virtual host configuration files.
include /etc/nginx/sites-enabled/*;

create your domain vhost configuration

nano /etc/nginx/sites-available/domain

add this but remember to edit and refer to your domain root

symlink your domain vhost configuration

cd /etc/nginx/sites-enabled
ln -s /etc/nginx/sites-available/domain
/etc/init.d/nginx restart

Install PHP 5.3.5 and required modules

yum --enablerepo=remi -y install php-cli php php-mcrypt php-devel php-mbstring spawn-fcgi sudo patch libtool libmcrypt-devel libxml2-devel make automake gcc gcc-c++ sudo flex bison wget zlib-devel openssl-devel pcre pcre-devel pcre-devel gd-devel bzip2* libc-client-devel.i386

Add script to start-stop-restart fastcgi

mv php-fastcgi /etc/init.d/
chmod +x /etc/init.d/php-fastcgi
chkconfig --add php-fastcgi
chkconfig php-fastcgi on

Turn off require tty

nano /etc/sudoers

find “Defaults requiretty” and deactivate or give comment (#) in the beginning line, so it will be like this:

#Defaults requiretty

Restart nginx

/etc/init.d/nginx restart

Install MySQL

yum --enablerepo=remi -y install mysql-server php-mysql
/etc/init.d/mysql start

for MySQL configuration, you can take a look on my previous post

Start fastcgi

/etc/init.d/php-fastcgi start

Check your PHP and Nginx version

php -v

PHP 5.3.5 (cli) (built: Jan 22 2011 10:11:01)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

nginx -v

nginx version: nginx/0.8.54

PHP 5.3.5 with FastCGI

Nginx 0.8.54

Install Ioncube Loader – eAccelerator – Suhosin

chmod 755

Install Ioncube Loader – XCache – Suhosin

chmod 755

Install PureFTPD
download and install PureFTPD

tar xvf pure-ftpd-1.0.29.tar.gz
cd pure-ftpd-1.0.29
make install-strip
echo "/usr/local/sbin/pure-ftpd &" >> /etc/rc.d/rc.local

start PureFTPD

/usr/local/sbin/pure-ftpd &

add user and password for your domain ftp

useradd domain
passwd domain

change owner your domain root

chown -R domain /home/domain

if you want to add user for ftp, i suggest you to create the same ftp username with your domain root folder name, and to manage your domain, use ssh login with your current ftp user (not root) so you don’t have to re-change-owner after add or edit some file.

Install phpMyAdmin
download and unpack phpMyAdmin


move phpMyAdmin directory to your domain directory

mv phpmyadmin /home/domain/public_html
chown -R nginx:nginx /var/lib/php/session

create phpMyAdmin pma database table

cd /home/domain/public_html/phpmyadmin/scripts
mysql -u root -p(yourmysqlrootpassword) < create_tables.sql
mysql -u root -p(yourmysqlrootpassword) < upgrade_tables_mysql_4_1_2+.sql

create and grant phpMyAdmin user to MySQL

mysql -u root -p(yourmysqlrootpassword)
CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'pmapass';
GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO 'phpmyadmin'@'localhost';

phpmyadmin = user
pmapass = password
you can change both of them but don’t forget to edit and adjust your phpMyAdmin pmadb setting in “”

if you’re using Suhosin, please add the following lines after declaring suhosin extension in php.ini


restart Nginx and PHPFastCGI

/etc/init.d/nginx restart
/etc/init.d/php-fastcgi restart

You can now use phpMyAdmin to manage your database

to prevent somebody from accessing your phpMyAdmin, you may not use “phpmyadmin” or some usual name like that for your phpMyAdmin directory name, also use robots.txt to prevent your phpMyAdmin directory indexed by search engine spider.

cd /home/domain/public_html
nano robots.txt

User-agent: *
Disallow: /phpmyadmin/

Thanks to
– Almighty God for my spirit
– Uncle G for plenty of knowledge
– A few helpful site and countless spam site that i cannot write here all

{ 10 comments… read them below or add one }

Leave a Comment

Previous post:

Next post: