zoukankan      html  css  js  c++  java
  • nginx使用vhost子目录

    在主配置文件http模块最后添加如下一句话
    
    
    [root@host-10-1-1-161 ~]# vi /etc/nginx/nginx.conf
    include /etc/nginx/conf.d/*.conf;
    
    [root@host-10-1-1-161 ~]# mkdir -p /etc/nginx/conf.d
    
    把主配置文件的server复制到conf.d下面就可以
     
    
    主配置文件实例:
    
    [root@bogon conf.d]# cat /etc/nginx/nginx.conf
    user root root;
    worker_processes  1;
    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"';
    
    server {
            listen 80;
            server_name www.test.com;
        charset    utf-8;
        location / {
        root /var/www/www.test.com;
            index index.php index.html index.htm;
            }
         
            location ~ .php$ {
            root html;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /var/www/www.test.com$fastcgi_script_name;
                include fastcgi_params;
            }
        }
        include /etc/nginx/conf.d/*.conf;    
    }
     
    
    子配置文件实例
    
    [root@bogon ~]# cat /etc/nginx/conf.d/test1.conf 
    server {
            listen 8083;
            server_name www.test1.com;
        charset    utf-8;
        location / {
        root /website;
            index index.php index.html index.htm;
            }
         
            location ~ .php$ {
            root html;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /website$fastcgi_script_name;
                include fastcgi_params;
            }
    
    }
  • 相关阅读:
    P3180 [HAOI2016]地图
    P2787 语文1(chin1)- 理理思维
    P2221 [HAOI2012]高速公路
    P4137 Rmq Problem / mex
    P3746 [六省联考2017]组合数问题
    P2461 [SDOI2008]递归数列
    P3715 [BJOI2017]魔法咒语
    P3195 [HNOI2008]玩具装箱TOY
    Linux下的strerror是否线程安全?
    bash/shell的字符串trim实现
  • 原文地址:https://www.cnblogs.com/effortsing/p/10012441.html
Copyright © 2011-2022 走看看