如何设置nginx的虚拟域名及访问目录

首先进入nginx的配置文件nginx.conf;

  1.  1         #相当于在http模块再添加一个server模块
     2         server {
     3             #监听绑定80端口
     4             listen       80;
     5             #下面这个是域名,多个域名用空格隔开
     6             server_name  www.a.com bb.com;
     7             #本网站的根路径
     8             root   /绝对路径;
     9             #下面是默认首页
    10             location / {
    11                 index  index.html index.php;
    12             }
    13             #下面是针对本站所有.php文件进行处理的配置
    14             location ~ .php{
    15                 #加载fastcgi  一种处理方式
    16                  include fastcgi_params;
    17                 #fastcgi的参数 指定文件路径及参数,否则会有404或是file not find 提示
    18                 fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
    19                 #fastcgi的服务信息 ip:端口
    20                 fastcgi_pass 127.0.0.1:9000;
    21                 #fastcgi默认首页
    22                 fastcgi_index index.php;
    23             }
    24         }
原文地址:https://www.cnblogs.com/cnn2017/p/6753901.html