[英]unable to access php file nginx
我對nginx完全陌生。 我有一個基於帶有index.html的angular js的項目,並且在某個事件中,我對x.php文件執行一個angular http請求並從中獲取響應。 它在我的本地系統和基於apache的私人托管服務器上運行完美。 我創建了一個免費的ec2實例,並啟動了一個基於centos的linux實例,在該實例上托管了代碼並安裝了nginx。 這是我的nginx配置
server {
listen 80;
server_name mydomain.co.in www.mydomain.co.in;
location / {
root /var/www/html/indm;
index index.php index.html index.htm;
try_files $uri/ $uri /index.php?$query_string =404;
}
location ~ \.php$ {
try_files $uri $uri/ /index.php?q=$uri&$args =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
add_header Access-Control-Allow-Origin *;
proxy_set_header Access-Control-Allow-Origin $http_origin;
}
error_page 500 502 503 504 /50x.html;
起初,在該php文件上執行http請求時,它給了我500個網關錯誤。 我檢查了XHR請求。這是nginx error.log中的錯誤
[error] 17193#0: *2 rewrite or internal redirection cycle while internally redirecting to "/index.php", client: 42.111.38.254
我搜索了一下並更改了附加的“ = 404”以嘗試uri語句。 但是現在它重定向到404。 我想運行該php文件。 服務器Nginx服務器正在運行php fpm也正在運行
請幫忙
location ~ \\.php$
塊沒有根。 將root
語句移到server
塊中,以便兩個location
塊都繼承相同的值。
例如:
server {
...
root /var/www/html/indm;
location / {
...
}
location ~ \.php$ {
...
}
...
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.