I have successfully installed a laravel application on a nginx server running on arch linux. However when I try to view the app in web browser all routes return 404 except the default '/'. I know this because I have make:auth but I can't reach the register and login page.
I followed instructions I found via Google and created two folders, sites-available
and sites enabled
in /etc/nginx/
. I then created a config file for laravel app in /etc/nginx/sites-available
called niko
in sites available and symlinked to it like so ln --symbolic /etc/nginx/sites-available/niko /etc/nginx/sites-enabled/niko
.
Here are the contents of my configuration file /etc/nginx/sites-available/niko
.
server {
listen 80;
server_name niko;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html/niko/public;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
root /usr/share/nginx/html/niko/public;
include fastcgi.conf;
}
}
In my /etc/nginx/nginx.conf
I have this line just above the closing }
of the http {}
block:
include /etc/nginx/sites-enabled/*;
When I check in the nginx error log(/var/log/nginx/error.log
) I find this entries:
2019/06/14 10:59:22 [error] 5429#5429: *3 directory index of "/usr/share/nginx/html/niko/" is forbidden, client: 192.168.1.101, server>
2019/06/14 10:59:36 [error] 5429#5429: *3 open() "/usr/share/nginx/html/niko/public/login" failed (2: No such file or directory), clie>
2019/06/14 10:59:36 [error] 5429#5429: *3 open() "/usr/share/nginx/html/niko/public/login" failed (2: No such file or directory), clie>
2019/06/14 10:59:38 [error] 5429#5429: *3 open() "/usr/share/nginx/html/niko/public/login" failed (2: No such file or directory), clie>
2019/06/14 10:59:38 [error] 5429#5429: *3 open() "/usr/share/nginx/html/niko/public/login" failed (2: No such file or directory), clie>
2019/06/14 11:26:53 [error] 5429#5429: *7 open() "/usr/share/nginx/html/niko/public/login" failed (2: No such file or directory), clie>
2019/06/14 11:26:53 [error] 5429#5429: *7 open() "/usr/share/nginx/html/niko/public/login" failed (2: No such file or directory), clie>
2019/06/14 11:27:01 [error] 5429#5429: *7 open() "/usr/share/nginx/html/niko/index.php/login" failed (2: No such file or directory), c>
2019/06/14 11:27:01 [error] 5429#5429: *7 open() "/usr/share/nginx/html/niko/index.php/login" failed (2: No such file or directory), c>
2019/06/14 11:27:04 [error] 5429#5429: *7 open() "/usr/share/nginx/html/niko/index.php/login" failed (2: No such file or directory), c>
2019/06/14 11:27:04 [error] 5429#5429: *7 open() "/usr/share/nginx/html/niko/index.php/login" failed (2: No such file or directory),
I have been pulling out my hair for hours because I don't know where to check. I have tried several things but nothing seems to work. Your support is appreciated.
UPDATE:
My new /etc/nginx/sites-available/niko
is here
server {
listen 80;
server_name niko;
root /usr/share/nginx/html/niko/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
UPDATE 1: namei -l /usr/share/nginx/html/niko/
gives:
f: /usr/share/nginx/html/niko/
drwxr-xr-x root root /
drwxr-xr-x root root usr
drwxr-xr-x root root share
drwxr-xr-x root root nginx
drwxr-sr-x kali root html
drwxr-sr-x kali root niko