开发者社区> 问答> 正文

nginx增加虚似站点的方法

验证过的
1.修改ngnix.conf,增加站点
      server
      {
              listen       80;
              server_name www.****.com;
              index index.html index.htm index.php;
              root /nginx/htdocs/new/;
              error_page 404 http://www.***.com/error.html;
              error_page 500 http://www.***.com/error.html;

              if (-d $request_filename)
              {
                     rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
              }

              location ~ .*\.php?$
              {
                   include fcgi.conf;
                   fastcgi_pass 127.0.0.1:10080;
                   fastcgi_index index.php;
              }

#              location /log/
#              {
#                  alias /var/log/nginx/;
#                  index err.html;
#              }

              log_format access '$remote_addr - $remote_user [$time_local] "$request" '
                                    '$status $body_bytes_sent "$http_referer" '
                                    '"$http_user_agent" $http_x_forwarded_for';
              access_log /var/log/nginx/nginx_access.log access;
      }
完成后退出。

2.运行/nginx/sbin/nginx -t,检查配置文件是否写对,如成功将返回
9313#0: the configuration file /nginx/conf/nginx.conf syntax is ok
9313#0: the configuration file /nginx/conf/nginx.conf was tested successfully

3.运行ps -ef | grep "nginx: master process" | grep -v "grep" | awk -F ' ' '{print $2}' , 找到nginx的pid

4.最后使用kill -HUP **** (***是nginx的pid),杀掉NGINX的进程,这样一个新的虚似站点就配置完成了。

展开
收起
zyp1518 2011-07-20 16:56:55 11511 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
《Nginx 代理系统常用手册》 立即下载
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载