Skip to content

Simple & Fast Install of nginx with php on centos-5.x

January 4, 2011

I don’t like to talk so much so simply you have to:

1- install epel repo using:

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

2- install remi repo using:

rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

3- install nginx, php* and mysql:

yum -y install nginx php \
php-{fpm,gd,xml,xmlrpc,mbstring,mysql,imap,cli} \
mysql{,-server}.x86_64

Note: for 32bit systems remove the “.x86_64″ word.

4- edit /etc/nginx/nginx.conf so that:
- user should be apache (and chown apache.apache /var/log/nginx)
- change the following block from

location / {
root html;
index index.html index.htm;
}

to :

root /var/www/html;
index index.html index.php;

yes, remove the “location /{” and the “}” lines and change the document root.

5- uncomment the block starts with location ~ \.php$ { and edit it to be like this:

location ~ \.php$ {
#root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

be sure to replace /scripts by $document_root

6- service php-fpm start && chkconfig php-fpm on
7- service nginx start && chkconfig nginx on
8- service mysqld start && chkconfig mysqld on

finally be sure that selinux is at least in permissive mode using the getenforce and setenforce and /etc/selinux/config
also be sure that the system firewall is OK.

Now you’re done, try installing our darlings php apps like Drupal, Joomla, phpBB and others.
Have a problem ? just let me NO ;)

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: