I am very new to nginx. So I managed to setup with a lot of googling ready.
I have one pure php app running on this folder /var/www/html/app1
Next I want to build api links. So first I did this
composer create-project slim/slim-skeleton
I want to use the slim framework.So the slim-skeleton folder I renamed it as apitest. Next I adjusted my nginx config file its as below. Below I added this configuration
location /apitest {
alias /var/www/html/apitest1/public;
try_files $uri $uri/ /index.php$is_args$args;
location ~ .php$ {
include fastcgi.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass 127.0.0.1:9000;
}
}
but I keep getting 404 not found.
Hi Victor,
Actually in my /var/www/html another different folder app for pure php application. But I just went ahead with you suggestion.
I created a new folder for the slim/slim-skeleton as apiv1. Below is the error log I got
2018/06/05 01:29:30 [error] 12246#0: 9 open() “/var/www/html/apiv1/public/50x.html” failed (2: No such file or directory), client: ..., server: _, request: “GET /apiv1/ HTTP/1.1”, upstream: “fastcgi://127.0.0.1:9000”, host: "...*"
I have check /var/www/html/apiv1/public this folder exist and even there index.php in it too.
Here is my current full conf. Yet I am getting the same type of errors
2018/06/05 01:50:18 [error] 12287#0: *9 open() “/var/www/html/50x.html” failed (2: No such file or directory), client: , server: _, request: “GET /apiv1/token HTTP/1.1”, upstream: “fastcgi://127.0.0.1:9000”, host: ""
But if just to till the /apiv1 then I get 503 forbidden.
2018/06/05 01:51:19 [error] 12287#0: *13 directory index of “/var/www/html/apiv1/” is forbidden, client: , server: _, request: “GET /apiv1/ HTTP/1.1”, host: ""
I am just wondering could it be due to this file # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;?
The content of it is the php.conf.
Hi Victor,
I did like you suggested. Now when I got just to http://myip/apiv1 I get 403 forbidden. Next say I type http://myip/apiv1/token I get the index.php from /var/www/html.
Message: The stream or file “/var/www/html/apiv1/src/…/logs/app.log” could not be opened: failed to open stream: Permission denied
File: /var/www/html/apiv1/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php
For whole of the apiv1 folder I have given this chown -R nginx:nginx apiv1. Then I have created app.log in the logs folder too but still getting this error.
Hi Victor,
Ok let me explain first I tried to run the composer to install could not run on my sudo user then I back to root install it. Then I change the owner using chown command. Next the logs folder exist only the app.log dont exist. So using the root user I create the app.log file and then I change the owner to nginx. But it didnt work. Lastly I had to set the permission to 777 then it started to work which I feel is wrong and unsecured right.