2.安装配置
#tar zxvf nginx-xx.tar.gz
#cd nginx-xx
#./configure --with-http_stub_status_module //可添加统计模块
#make; make install
4.#ln -sf /opt/app/nginx/sbin/nginx /usr/sbin
5.编辑启动脚本
#chkconfig: - 99 20
#description: Nginx Service Control Script
case "$1" in
start)
/opt/app/nginx/sbin/nginx
echo "Nginx is running"
;;
stop)
/usr/bin/killall -s QUIT nginx
echo "Nginx is stopped"
;;
$0 stop
$0 start
;;
echo "Usage: $0{start|stop|restart}"
exit 1
esac
exit 0
6.调整配置文件
user nobody;
worker_processes 10;
#error_log logs/error.log notice;
#error_log logs/error.log info;
events {
use epoll;
worker_connections 2048;
}
http {
include mime.types;
default_type application/octet-stream;
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
tcp_nopush on;
keepalive_timeout 65;
upstream www {
ip_hash;
server 192.168.2.10:80;
server 192.168.2.20:80;
}
listen 80;
server_name www.chinaunix.net;
location / {
proxy_pass http://www;
proxy_set_header x-real-IP $remote_addr;
}
}
server {
server_name localhost;
#charset koi8-r;
charset utf-8;
location / {
root html;
index index.php index.html index.htm;
}
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
## fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
location ~^/status {
stub_status on;
access_log off;
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
# ssl_prefer_server_ciphers on;
# root html;
# index index.html index.htm;
# }
#}
}
}
#tar zxvf lighttpd-xx.tar.gz
#cd lighttpd-xx
#./configure && make (只编译不安装)
#cp src/spawn-fcgi /usr/sbin
#spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi -C 16
在配置文件中开启php功能,重启服务