Wednesday, February 9, 2011

How to : install and config Nginx/PhP fastcgi on Centos

To Install Nginx, setup the prerequisites as following.

yum install GCC #C compiler
yum install pcre* # perl regular expression
yum install zlib zlib-devel
yum install openssl openssl-devel

Download Nginx From, and extract to a source folder, I will use /tmp here

-zxvf nginx-0.8.54.tar.gz
cd /tmp/nginx-0.8.54

./configure  --prefix=/opt/nginx
make && make install

once done, you can run ./nginx –? to show all available options ,


for the default loading, it read the conf file which is  conf/nginx.conf 
to start the nginx, just run ./nginx, you will get the helloworld page.


here, I changed ngingx.conf a little with a New port 88, and basic proxy forward to Apache,PHP (check installation instructions, Install PHP to Apache web server)

server {
        listen       88;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

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

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;

        # proxy the PHP scripts to Apache listening on
       location ~ \.php$ {

if I access http://localhost:88/info.php, nginx will forward the request to http://localhost/info.php

But the server header is nginx Now. Also the ngnix has enabled the GZIP support now. ( a great reverse proxy, offloading those cut-off features)


more how-tos:

How to: install apache 2.2 on centos
How To: Install PHP to Apache web server

No comments:

Locations of visitors to this page