Chinaunix首页 | 论坛 | 博客
  • 博客访问: 707735
  • 博文数量: 143
  • 博客积分: 1554
  • 博客等级: 上尉
  • 技术积分: 1767
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-10 11:50
文章分类

全部博文(143)

文章存档

2017年(2)

2016年(5)

2015年(16)

2014年(25)

2013年(27)

2012年(16)

2011年(52)

分类: 系统运维

2011-06-30 18:07:43

一、安装Nginx
1.安装Nginx所需的pcre库
 用rpm包安装pcre/pcre-devel两个包
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.编辑启动脚本
#!/bin/bash
#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"
 ;;
 restart)
   $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;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#pid        logs/nginx.pid;

events {
    use epoll;
    worker_connections  2048;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  logs/access.log  main;
    sendfile        on;
    tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    #gzip  on;
upstream www {
 ip_hash;
 server 192.168.2.10:80;
 server 192.168.2.20:80;
}
 server {
             listen     80;
             server_name        ;
             location / {
                proxy_pass      ;
                proxy_set_header x-real-IP $remote_addr;
                }
        }

    server {
        listen       80;
        server_name  localhost;
        #charset koi8-r;
 charset utf-8;
        access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.php 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 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   ;
        #}
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        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;
        }
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
#### http_stub_status  ////
        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;
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;
    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;
    #    ssl_session_timeout  5m;
    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    #    ssl_prefer_server_ciphers   on;
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
}

}
7.编辑lighttpd,取出spawn-fcgi工具,利用该工具启动php
#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功能,重启服务
阅读(1465) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~