zoukankan      html  css  js  c++  java
  • Nginx高性能服务器安装、配置、运维 (5) —— Nginx虚拟主机配置

     

    六、Nginx虚拟主机配置

     

    建立基于域名的虚拟主机:

    (1)建立基于域名的虚拟主机配置文件(以abc.com为例):

     

     

    (2)更改虚拟主机配置文件:

     

     

    更改配置如下(更改部分即可):


    server {
    listen 80;                  #侦听端口
    server_name abc.com;              #虚拟机主机名(这里填入域名绑定)

    #charset koi8-r;               
    #access_log /var/log/nginx/log/host.access.log main;    
    root /mnt/www/abc.com;              #指定WEB根目录
    location / {
    index index.php index.html index.htm;       #指定默认读取文件(读取顺序从左往右)
    }

    #error_page 404 /404.html;          

    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    root /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ .php$ {
    # proxy_pass http://127.0.0.1;
    #}

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

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /.ht {
    # deny all;
    #}
    }

    (以上是基于域名的Nginx虚拟主机基本配置,更详细的配置请见LNMP配置)

    配置完成,重新加载服务:

    (本文由kayvan编辑发表,内容主要收集于互联网,转载请注明出处:http://www.cnblogs.com/kayvan


  • 相关阅读:
    C++ 纸牌 今日头条面试题
    c++ 病句 今日头条面试题
    C++ 球迷 今日头条面试题
    C++ 活动安排
    C++ 弗洛伊德算法
    填坑 bzoj3337
    bzoj3884 上帝与集合的正确用法
    人参中第一次膜你退货
    洛谷P2216 [HAOI2007]理想的正方形
    洛谷 P1099 树网的核+P2491 [SDOI2011]消防
  • 原文地址:https://www.cnblogs.com/kayvan/p/3978561.html
Copyright © 2011-2022 走看看