nginx 服务器配置虚拟域名

1.修改配置文件nginx.conf,添加:

include vhost/*.conf;

2.创建vhost目录,并在下面创建虚拟机配置文件web1.conf。

mkdir vhost && cd vhost

web1.conf 内容如下:

server{
        listen 80;
        server_name  crm6api.credithc.com;
        #include /opt/www/crm6api/public/.htaccess;
      
    
     #配置访问域名可省略index.php location
/ { index index.html index.htm index.php; #autoindex on; if ($request_filename !~ (static|robots/.txt|index/.php.*)) { rewrite ^/(.*)$ /index.php?$1 last; break; } } location ~ .php(.*)$ { root /opt/www/crm6api/public; #index index.php index.html index.htm fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }

3.windows修改配置文件hosts,并测试是否可访问。

10.100.110.110 web1.com
原文地址:https://www.cnblogs.com/wjs2019/p/15308618.html