phpStudy2018 Nginx404

phpStudy2018 Nginx404

問題描述

phpstudy2018 使用php7+nginx,前半天還一直沒問題,也不知道怎么了,后面加了一個站點(diǎn)配置,就突然出現(xiàn)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,查詢許多關(guān)于目錄斜杠問題

windows系統(tǒng)中,正斜杠 / 表示除法,用來進(jìn)行整除運(yùn)算;反斜杠 用來表示目錄。在unix系統(tǒng)中,/ 表示目錄; 表示跳脫字符將特殊字符變成一般字符(如enter,$,空格等)。

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

2,訪問配置的虛擬目錄時,可以訪問到框架的入口文件,但無法訪問到虛擬目錄對應(yīng)的模塊(啟用了項目分組)

立即學(xué)習(xí)PHP免費(fèi)學(xué)習(xí)筆記(深入)”;

集成環(huán)境自動生成的vhost.conf文件中缺少兩行配置語句句

if (!-e $request_filename) {      rewrite ^/(.*)$ /index.php/$1 last;  }

這兩句話的意思是指,如果請求的文件不存在,則進(jìn)行路徑的重寫

改完以后的vhost.conf文件內(nèi)容為

server {         listen       80;         # 網(wǎng)站域名         server_name  demo.local ;         # 代碼根目錄         root   "D:/homestead/code/demo/api/public";         location / {              # 默認(rèn)請求的文件排序             index  index.html index.htm index.php;             # 判斷請求的文件是否存在             if (!-e $request_filename) {                  # 如果不存在就進(jìn)行重定向                 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極速入門視頻教程

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點(diǎn)贊14 分享