Heim  >  Artikel  >  Betrieb und Instandhaltung  >  phpStudy2018 Nginx404

phpStudy2018 Nginx404

步履不停
步履不停Original
2019-07-03 16:52:537958Durchsuche

phpStudy2018 Nginx404

问题描述

phpStudy2018 使用php7+nginx,前半天还一直没问题,也不知道怎么了,后面加了一个站点配置,就突然出现404问题,查看日志

2019/07/02 19:56:12 [error] 12448#1000: *1 CreateFile() "D:/homestead/code/**/api/public/api/login" failed (3: The system cannot find the path specified), client: 127.0.0.1, server: **-api.local, request: "POST /api/login HTTP/1.1", host: "**-api.local"

1,查询许多关于目录斜杠问题

在Windows系统中,正斜杠 / 表示除法,用来进行整除运算;反斜杠 \ 用来表示目录。
在Unix系统中,/ 表示目录;\ 表示跳脱字符将特殊字符变成一般字符(如enter,$,空格等)。

然后就将vhosts.conf配置文件和nginx.conf的root都改为正斜杠

2,访问配置的虚拟目录时,可以访问到框架的入口文件,但无法访问到虚拟目录对应的模块(启用了项目分组)

集成环境自动生成的vhost.conf文件中缺少两行配置语句句

if (!-e $request_filename) {

    rewrite ^/(.*)$ /index.php/$1 last;

}

这两句话的意思是指,如果请求的文件不存在,则进行路径的重写

改完以后的vhost.conf文件内容为

server {
        listen       80;
        # 网站域名
        server_name  demo.local ;
        # 代码根目录
        root   "D:/homestead/code/demo/api/public";
        location / {
             # 默认请求的文件排序
            index  index.html index.htm index.php;
            # 判断请求的文件是否存在
            if (!-e $request_filename) {
                 # 如果不存在就进行重定向
                rewrite ^/(.*)$ /index.php/$1 last;
            }
            #autoindex  on;
        }
        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;
        }
}

推荐教程:phpStudy极速入门视频教程

Das obige ist der detaillierte Inhalt vonphpStudy2018 Nginx404. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn