apt-get install php5-cgi php5-mysql php5-gd -yf --force-yes;
2、安装nginx
首先安装一些必须的软件(pcre和zlib):
apt-get install libpcre3-dev -yf --force-yes;
apt-get install zlib1g-dev -yf --force-yes;
debian下用apt-get可以安装nginx的0.6.32版,但我通常不用这个版本,比较旧了,所以下载nginx编译安装:
wget http://sudone.com/download/nginx/nginx-0.7.30.tar.gz -O /tmp/nginx.tar.gz
cd /tmp/
tar -zxf nginx.tar.gz
cd nginx-0.7.30
./configure --with-http_realip_module --prefix=/usr/local/nginx/ --with-poll_module --with-cpu-opt=pentium4 --with-md5=/usr/lib --with-sha1=/usr/lib --with-openssl=/usr/lib --with-http_sub_module --with-cc-opt="-I /usr/include/pcre"
make -j10
make install
3、使用spawn-fcgi启动php
cd /usr/local/nginx/sbin
wget http://sudone.com/download/spawn-fcgi
chmod +x spawn-fcgi
spawn-fcgi -a 127.0.0.1 -p 9000 -u nobody -f /usr/bin/php-cgi -C 20
echo "/usr/local/nginx/sbin/spawn-fcgi -a 127.0.0.1 -p 9000 -u nobody -f /usr/bin/php-cgi -C 20" >> /etc/rc.local
4、配置nginx(例子)
server {
include port.conf;
server_name test.com;
location / {
root /www;
index index.html index.htm index.php;
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www$fastcgi_script_name;
include fastcgi_params;
}
}
启动和重启nginx:
启动:/usr/local/nginx/sbin/nginx
重启:kill -HUP `cat /usr/local/nginx/logs/nginx.pid`或killall -9 nginx;/usr/local/nginx/sbin/nginx
5、php的配置
php配置文件php.ini位置在/etc/php5/cgi/php.ini,有需要就修改这个文件,并用下面这条语句重启php-cgi:
killall -9 php-cgi; spawn-fcgi -a 127.0.0.1 -p 9000 -u nobody -f /usr/bin/php-cgi -C 20
声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。