Wednesday, August 20, 2008

Nginix + php howto

#1. install the needed packages
$apt-get install php5-cli php5-cgi build-essential libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev
#2. install nginix from source

$mkdir -p /opt/build/nginx
$cd /opt/build/nginx
$wget --continue http://sysoev.ru/nginx/nginx-0.7.32.tar.gz
$tar -zxvf nginx-0.6.32.tar.gz
$cd nginx-0.6.32
$./configure --prefix=/opt/nginx --with-http_flv_module
$make
$sudo make install
#3.install fast cgi support for php http://www.howtoforge.com/nginx_php5_fast_cgi_xcache_ubuntu7.04



wget http://www.lighttpd.net/download/lighttpd-1.4.19.tar.gz
tar -zxvf lighttpd-1.4.19.tar.gz
cd lighttpd-1.4.19
./configure ; make

cp src/spawn-fcgi /usr/bin/spawn-fcgi

sudo vi /usr/bin/php-fastcgi

#!/bin/sh
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -f /usr/bin/php5-cgi


sudo chmod +x /usr/bin/php-fastcgi

update-rc.d init-fastcgi defaults


/etc/init.d/init-fastcgi start

in nginx conf uncomment add these lines

location ~ \.php$ {
root /var/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/$fastcgi_script_name;
include fastcgi_params;
}



and you should start the nginix server

$/opt/nginx/sbin/nginx

load the http://localhost




You can add an init script for it this way

No comments: