折腾了有一天的新建项目,一开始我是复制的一个项目,然后直接配,host增加一个,然后再在\nginx\conf\vhost这边复制上一个可以用的*.conf然后修改路径和本地域名,其中物理路径就是直接到文件夹里面复制的,见下代码
server {
listen 80;
server_name b.test.com;
#罪恶的来源就是下面的一行
root "D:\phpStudy\PHPTutorial\WWW\WWW\test";
location / {
// 以下者三行是配置nginx以pathinfo形式访问
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
index index.html index.htm index.php;
#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;
}
}
然后自己尝试直接新建个文件夹在里面写个index.php都不行,我看,这是有毒吧~随后想到我可以看看nginx的报错日志啊
,于是我去D:\phpStudy\PHPTutorial\nginx\logs,把error.log打开
2018/07/09 14:35:00 [crit] 6652#10176: *1 GetFileAttributesEx() "D:\phpStudy\PHPTutorial\WWW est/" failed (123: The filename, directory name, or volume label syntax is incorrect), client: 127.0.0.1, server: b.test.com, request: "GET / HTTP/1.1", host: "b.test.com"
2018/07/09 14:35:00 [crit] 6652#10176: *1 GetFileAttributesEx() "D:\phpStudy\PHPTutorial\WWW est/favicon.ico" failed (123: The filename, directory name, or volume label syntax is incorrect), client: 127.0.0.1, server: b.test.com, request: "GET /favicon.ico HTTP/1.1", host: "b.test.com", referrer: "http://b.test.com/"
2018/07/09 14:35:00 [crit] 6652#10176: *1 GetFileAttributesEx() "D:\phpStudy\PHPTutorial\WWW est/" failed (123: The filename, directory name, or volume label syntax is incorrect), client: 127.0.0.1, server: b.test.com, request: "GET / HTTP/1.1", host: "b.test.com"
2018/07/09 14:35:00 [crit] 6652#10176: *1 GetFileAttributesEx() "D:\phpStudy\PHPTutorial\WWW est/favicon.ico" failed (123: The filename, directory name, or volume label syntax is incorrect), client: 127.0.0.1, server: b.test.com, request: "GET /favicon.ico HTTP/1.1", host: "b.test.com", referrer: "http://b.test.com/"
情况2
2018/10/08 11:20:24 [crit] 10652#203872: *3 CreateFile() “D:\phpstudy\PHPTutorial\WWW
ihao/favicon.ico” failed (123: The filename, directory name, or volume label syntax is incorrect), client: 127.0.0.1, server: nihao.com, request: “GET /favicon.ico HTTP/1.1”, host: “nihao.com”, referrer: “http://nihao.com/”
我的文件名是nihao,然后被解析了,换行了,尴尬。
尼玛这特么什么鬼,解析的路径咋解析成这样了,D:\phpStudy\PHPTutorial\WWW est/favicon.ico,这样是不行的啊,于是我一开始以为是\t惹的祸,但是测试其他字母没有啊,我于是把这个“\”换成了这个“/”,哎可以了,真心不容易,记录一下吧,望后人看到候勉励下