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


  • 相关阅读:
    HyperV Server 2008 R2 包含简体中文 下载
    Javascript实现把网页中table的内容导入到excel中的几种方法
    C# WebRequest WebClient Post请求 无乱码
    聊聊我对开发项目选技术的看法
    聊聊我对开发项目选技术的看法2
    企业的虚拟化发展
    不成文的期望
    Deep Zoom Composer 小工具 三步 5分钟
    2009829 周末
    复制文章时自动在文章末尾加上来源网址的代码
  • 原文地址:https://www.cnblogs.com/kayvan/p/3978561.html
Copyright © 2011-2022 走看看