phpstudy的nginx配置虚拟主机方法

小云云
小云云 原创
2023-03-21 15:54:02 7171浏览

本文主要和大家分享phpstudy的nginx配置虚拟主机方法,希望能帮助到大家。

打开目录 nginx-conf

server {
        listen       80;
        server_name  www.restfulapi.com/;      //自己配置的虚拟域名
        root   "E:/phpstudy/WWW/restfulapi/restful";//写到你指向的最终rewrite地址
        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(.*)$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
}、

配置host,添加自己域名配置,例如

127.0.0.1 www

127.0.0.1 www.restfulapi.com
127.0.0.1 www.api.com
192.168.1.103 oatest1.com

重启nginx服务器

相关推荐:

win10 apache配置虚拟主机后localhost无法使用

关于php之Apache配置虚拟主机

php与apache的集成、配置虚拟目录、配置虚拟主机

以上就是phpstudy的nginx配置虚拟主机方法的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。