正在为你努力加载中........

点滴记录 分享
13
2014-5
首页 >> linux >> nginx 配置虚拟hosts

nginx 配置虚拟hosts

nginx配置虚拟的hosts其实和apache的vhosts差不多

1:打开nginx.conf文件

在http{

    include /usr/local/nginx/vhosts/*.conf;

}

然后一个项目一个conf文件即可

举例配置文件:

    server {
        listen       80;
        server_name  example1.com www.example1.com;

        #charset koi8-r;

        #access_log  /web/example1/access_example1.log  main;
		access_log  /web/example1/example1.access.log  main;
        location / {
            root   /web/example1;
            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   /web/example1;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           /web/example1;
            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;
        #}
    }


作者:一根烟的寂寞 分类:linux
浏览:2563 评论:0

发表评论: