开发者社区> 问答> 正文

nginx增加虚似站点的方法

zyp1518 2011-07-20 16:56:55 10119
验证过的
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的进程,这样一个新的虚似站点就配置完成了。
应用服务中间件 PHP nginx Perl
分享到
取消 提交回答
全部回答(0)

集结各类场景实战经验,助你开发运维畅行无忧

推荐文章
相似问题
推荐课程