win7下关于nginx配置的路径问题

来源:互联网 发布:阿里云https部署 编辑:程序博客网 时间:2024/05/21 16:54

从github上拉下来的项目

然后在nginx配置文件中配置项目路径:如下

server {listen   8883;server_name localhost;index index.php index.html index.htm;set $root_path 'F:\PHP+Nginx\Workspace\Tour\tour-of-api\public';root $root_path;......... //省略}
在访问项目的时候报错404 notfound

然后查看nginx的日志文件:error.log文件,发现报错,如下:

2017/09/09 17:44:04 [crit] 5912#5800: *28 GetFileAttributesEx() "F:\PHP+Nginx\Workspace\Tourour-of-api\public/index.php" failed (123: 
The filename, directory name, or volume label syntax is incorrect), client: 127.0.0.1, server: localhost,
 request: "GET /api/index/index HTTP/1.1", host: "localhost:8883"
发现 F:\PHP+Nginx\Workspace\Tour       our-of-api  中间多了一个tab

网上查找,发现是nginx配置的路径问题,由于在Windows下文件路径可以用”\”, 也可以用”\\”, 也可以用”/”作为路径做分隔符。但”\”最容易引发问题,所以要尽量避免使用。

修改配置文件,如下

server {listen   8883;server_name localhost;index index.php index.html index.htm;set $root_path 'F:\PHP+Nginx\Workspace\Tour/tour-of-api\public';root $root_path;......... //省略}

项目访问成功!


原创粉丝点击