zoukankan      html  css  js  c++  java
  • nginx虚拟主机

    1 需求

    一台服务器的nginx上如果需要运营多个网站,或者把二级域名拆分成不同的web映射目录。就需要使用vhost。web client上请求不同的域名,nginx会根据vhost里的server conf加载不同的配置。

    2 配置

    conf/nginx.conf

    不需要server标签,只要在http标签的最后加上一个include

    (conf文件是在conf/vhost/里面,但是这里不是写conf/vhost/*.conf,踩坑了。)

    worker_processes  1;
    error_log  logs/error.log  error;
    
    events {
        worker_connections  1024;
    }
    
    http {
    
    
        include       mime.types;
        default_type  application/octet-stream;
    
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';
    
        #access_log  logs/access.log  main;
    
        sendfile        on;
        include vhost/*.conf;
    }
    

      

    conf/vhost/jab.com.conf 

    server {
        listen       80;
        server_name  www.jab.com jab.com;
        root         /data/jab.com/;
        #charset koi8-r;
    
        access_log  logs/jab.com.log  main;
    
        location / {
            root /data/jab.com/;
            index index.php index.html;
        }
    
        location ~ .php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
    

      

  • 相关阅读:
    建造者模式
    js日期转化(计算一周的日期)
    vue实现全选效果
    less入门
    使用node初始化项目
    ES5新语法forEach和map及封装原理
    es6中的promise对象
    深入理解jsonp跨域请求原理
    markdown语法与使用
    Ajax商品分类三级联动实现
  • 原文地址:https://www.cnblogs.com/jabbok/p/9242761.html
Copyright © 2011-2022 走看看