zoukankan      html  css  js  c++  java
  • nginx多站设置

    简介:这是nginx多站设置的详细页面,介绍了和php,有关的知识、技巧、经验,和一些php源码等。

    class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=339495' scrolling='no'>

      关于nginx的多站设置,其实和apache很相似,假设我们已经有两个域名,分别是:www.websuitA.com和www.websuitB.com。并且这两个域名已经映射给了IP为192.168.1.1的服务器。那么我们开始吧:

    1、为我们的站点创建配置文件

      我是这么做的,在nginx的配置文件conf目录下创建一个专门存放VirtualHost的目录,命名为vhosts_conf,可以把虚拟目录的配置全部放在这里。在里面创建名为vhosts_modoupi_websuitA.conf的配置文件并打开,我们在这里做配置,往里面写:

    server {
    listen 80;               #监听的端口号
    server_name websuitA.com;        #域名

    #access_log logs/host.access.log main;

    location / {
    root X:/wnmp/www/websuitA;    #站点的路径
    index default.php index.php index.html index.htm;

    #站点的rewrite在这里写
      rewrite ^/(\w+)\.html$ /$1.php;  
    rewrite ^/(\w+)/(\w+)$ /$1/$2.php; 
    }
          #错误页的配置
    error_page 404 /error.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root html;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
    root X:/wnmp/www/websuitA;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }

    location ~ /\.ht {
    deny all;
    }
    }

    这样就做好了,站点A的配置,同样的方法,做websuitB的配置,这里我命名为vhosts_modoupi_websuitB.conf,直接上代码

    server {
         listen 80;               #监听的端口号
         server_name websuitB.com;        #域名

         #access_log logs/host.access.log main;

         location / {
            root X:/wnmp/www/websuitB;    #站点的路径
           index default.php index.php index.html index.htm;


    #站点的rewrite在这里写

           rewrite ^/(\w+)\.html$ /$1.php;
           rewrite ^/(\w+)/(\w+)$ /$1/$2.php;
         }

      #错误页的配置

         error_page 404 /error.html;

         error_page 500 502 503 504 /50x.html;
         location = /50x.html {
           root html;
         }

         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
         location ~ \.php$ {
            root X:/wnmp/www/websuitB;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
         }

         location ~ /\.ht {
            deny all;
         }
    }

    这样,两个站点的配置就OK了。

    2、在nginx的主配置文件里,包含这两个站点的配置文件。

      我们打开conf目录下的nginx.conf文件,很容易做,只要在http{...}段输入以下代码:

    #包含所有的虚拟主机的配置文件
    include X:/wnmp/nginx/conf/vhosts_conf/*.conf;
    这样,nginx的多站点配置就做好了,怎么样打开浏览器测试一下吧~

    爱J2EE关注Java迈克尔杰克逊视频站JSON在线工具

    http://biancheng.dnbcw.info/php/339495.html pageNo:8
  • 相关阅读:
    atitit,it人怎么样才容易事业成功?? 有以下五种性格的人容易成功
    atitit。win7 win8 win9 win10 win11 新特性总结与战略规划
    atitit.提升兼容性最佳实践 o9o
    atitit.attilax.com产品 软件项目通用框架类库总结
    atitit. 文件上传带进度条 atiUP 设计 java c# php
    atitit.窗体静听esc退出本窗体java swing c# .net php
    atitit.提升研发管理的利器---重型框架 框架 类库的区别
    atitit.导出excel的设计----查询结果 导出为excel的实现java .net php 总结
    atitit. java跟php的比较..为什么大企业喜欢java 而不是php
    atitit. java jsoup html table的读取解析 总结
  • 原文地址:https://www.cnblogs.com/ooooo/p/2246160.html
Copyright © 2011-2022 走看看