I try to enable PHP for only one subdirectory (the laravel directory) but I didn't manage to get this working. NGINX is always saying 404 File not found or php says "no input file specifed". What am I doing wrong?
This is my location config:
location /laravel {
root html/laravel/public;
index index.php index.html index.html;
try_files $uri $uri/ /index.php?$query_string;
location ~ \.php$ {
root html/laravel/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME document_root$fastcgi_script_name;
#include fastcgi_params;
include fastcgi.conf;
}
}
UDPATE 1: It seems that nginx does not properly evaluate my location expressions:
2018/09/12 16:30:44 [error] 26476#24408: *1 CreateFile() "C:/Server/nginx/html/index.php" failed (2: The system cannot find the file specified), client: 127.0.0.1, server: localhost, request: "GET /laravel/ HTTP/1.1", host: "localhost"
This is the wrong path and at least the root of the / location:
location / {
root C:/Server/nginx/html;
index index.html index.htm index.php;
}
I tried to move the block but nothing changes.
UPDATE 2: It seems that nginx is very buggy. The documentation states:
Checks the existence of files in the specified order and uses the first found file for request processing; the processing is performed in the current context. The path to a file is constructed from the file parameter according to the root and alias directives. It is possible to check directory’s existence by specifying a slash at the end of a name, e.g. “$uri/”. If none of the files were found, an internal redirect to the uri specified in the last parameter is made.
As my error log shows, The try_files directive does not respect the root path because it trys to open the file relative to another location block.
$in$document_root. Also, you are passing uncontrolled requests to PHP.try_filesstatement should be/laravel/index.php. You currently have/index.phpwhich will be processed by thelocation /block, which explains the error log entry in your EDIT./some/path/to/html/laravel/public/laravel/index.php? Should you be usingaliasinstead ofroot? See my answer here;