English 简体 繁體 Tiếng Việt
  • 注册
  • 建站 建站 关注:1 内容:5

    windows下Nginx配置多域名主机

  • 查看作者
  • 打赏作者
    • 1
    • 建站
    • windows下Nginx配置多域名主机

      进入conf文件夹,新建vhost文件夹;

      将内部的server配置段提取单独放在一个文件里,存到了conf/vhost下,以方便配置多个虚拟主机。

      并在nginx.conf里http配置段内添加了一行 include vhost/*.conf;用来读取vhost下的虚拟主机配置。

      http {
          include       mime.types;
          default_type  application/octet-stream;
          sendfile        on;
          keepalive_timeout  65;
          include vhost/*.conf;  #新增
      }

      配置主机:

      进入vhost文件,新建一个mall.conf(你自己想取的名字)文件。

      server {
              listen       80;
              server_name  mall.me; #可添加多个,多个之间“空格”分开
              #autoindex on;#打开目录浏览,这样当没有找到index文件,就也已浏览目录中的文件
              location / {
                  root   F:/wnmp/wwwroot/mall;
                  index  index.html index.htm index.php;
                  #此处是伪静态配置
                  if (!-e $request_filename) {
                      rewrite  ^(.*)$  /index.php/?/$1  last; 
                      break;
                  } 
              }
              error_page   500 502 503 504  /50x.html;
              location = /50x.html {
                  root   F:/wnmp/wwwroot;
              }
              location ~ \.php$ {
                  root           F:/wnmp/wwwroot/mall;
                  fastcgi_pass   127.0.0.1:9000;
                  fastcgi_index  index.php;
                  fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                  include        fastcgi_params;
              }
          }

      然后重启你的Nginx服务器。

      LV10
      水晶之恋

      这个逼装的我给82分,剩下的用666的方式打给你!

      回复

      请登录之后再进行评论

      登录
    • 任务
    • 管理
    • 回底部
    • 帖子间隔 侧栏位置: