I'm trying to set up nginx configuration file for multi-project php located in different folders. I have the following configuration file in my production server.
server {
listen 80;
error_log /LOGS/ardu_error.log debug;
access_log /LOGS/ardu_access.log;
set $applicationEnv "production";
location ~ /ardu-component/ {
root /srv/www/ardu-component/;
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
# the ubuntu default
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param APPLICATION_ENV $applicationEnv;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
#return 404 for all php files as we do have a front controller
location ~ \.php$ {
return 404;
}
}
server {
listen 80;
error_log /LOGS/ardu_error.log debug;
access_log /LOGS/ardu_access.log;
set $applicationEnv "production";
location ~ /ardu-component/ {
root /srv/www/ardu-component/;
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
# the ubuntu default
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param APPLICATION_ENV $applicationEnv;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
#return 404 for all php files as we do have a front controller
location ~ \.php$ {
return 404;
}
}
I open my browser and I tried to connect to /ardu-component/ and I get File not found error from nginx.
In nginx debug log, I see the following information. It seems to start well resolving location and stuff, but it ends up in /usr/share/nginx... and I did not configure that in conf. I'm not devops, so I don't know how to solve this.
2019/09/18 23:14:21 [debug] 2720#2720: *4 http script var: "/ardu-component/" 2019/09/18 23:14:21 [debug] 2720#2720: *4 trying to use file: "/ardu-component/" "/srv/www/ardu-component/ardu-component/" 2019/09/18 23:14:21 [debug] 2720#2720: *4 http script copy: "/index.php" 2019/09/18 23:14:21 [debug] 2720#2720: *4 http script var: "" 2019/09/18 23:14:21 [debug] 2720#2720: *4 trying to use file: "/index.php" "/srv/www/ardu-component/index.php" 2019/09/18 23:14:21 [debug] 2720#2720: *4 internal redirect: "/index.php?" 2019/09/18 23:14:21 [debug] 2720#2720: *4 rewrite phase: 1 ... 2019/09/18 23:14:21 [debug] 2720#2720: *4 http script var: "/usr/share/nginx/html" 2019/09/18 23:14:21 [debug] 2720#2720: *4 http script var: "/index.php" 2019/09/18 23:14:21 [debug] 2720#2720: *4 fastcgi param: "SCRIPT_FILENAME: /usr/share/nginx/html/index.php" 2019/09/18 23:14:21 [debug] 2720#2720: *4 http script copy: "HTTPS" 2019/09/18 23:14:21 [debug] 2720#2720: *4 http script copy: "off" 2019/09/18 23:14:21 [debug] 2720#2720: *4 fastcgi param: "HTTPS: off"
Thanks in advance.