NGINX访问错误path中的文件

我有一个codeigniter应用程序具有以下目录结构

<HOME> |_ <web> | |_<API> | |_index.php |_<admin> 

开发人员在目录中有一个index.html。 codeigniter文件和开发人员推出的服务都在目录中。 开发人员通过将服务名称附加到域来访问服务,如下所示:http://mydomain/web/API/index.php/v1/GetRoles主机名在JavaScript文件中被configuration为BASE PATHvariables。

这个程序是由运行fast-CGI的NGINX服务的。

虽然HTML页面被加载,但是没有数据被获取。 所以我们试图通过在浏览器中inputURL( http://mydomain/web/API/index.php/v1/GetRoles )来访问这些函数。 我们得到一个404 Not Found错误。 错误日志包含以下条目

 2016/05/20 16:14:57 [error] 2127#0: *232 FastCGI sent in stderr: "Unable to open primary script: /home/myname/public_html/domainname/public/projectname/index.php (No such file or directory)" while reading response header from upstream, client: 14.141.163.46, server: mydomain.com, request: "GET /web/API/v1/get/Common/GetActivities HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "mydomain.com" 

服务器应该在/home/myname/public_html/domainname/public/projectname/web/API/index.php中查找index.php,而不是在WEB ROOT中查找它。

我的NGINXconfiguration如下

 server { listen mydomain.com; server_name mydomain.com; root /home/myname/public_html/domainname/public/projectname; keepalive_timeout 70; access_log /home/myname/public_html/domainname/log/access.log; error_log /home/myname/public_html/domainname/log/error.log; gzip_static on; index index.html index.php; location / { try_files $uri $uri/ /index.php?$query_string; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/www; } # pass the PHP scripts to FastCGI server listening on the php-fpm socket location ~ \.php$ { #try_files $uri =404; #fastcgi_pass unix:/tmp/php5-fpm.sock; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_intercept_errors on; } } 

我无法弄清楚为什么NGINX在WEB ROOT中寻找index.php,而不是加载任何我们input的URL。 期待听到类似问题的人的消息。

据我所见你的请求,你试图得到/web/API/v1/get/Common/GetActivities ,这不是一个真正的文件夹。 您可以使用root /home/myname/public_html/domainname/public/projectname/web/API执行location /web/API/v1/get/Common/GetActivities ,或在/web/API/index.php上更改您的请求path