It’s been quite a long time since I’ve asked a question as I can usually find an answer somewhere but in this case, I’m stumped.
I’ve been battling with a Ubuntu install on a VPS and have got everything working now apart from issues with Nginx.
I had permissions errors in the log file and I think I’ve resolved them, but now I’m getting an Nginx 404 error. I know what the problem is, it’s looking in the wrong place. Instead of using the root path in the server block, it’s cutting part of it off.
I’ve installed Laravel 11 so my root path is /var/www/my-domain.com/public_html/public
but in the Nginx error.log, I get this error. It’s stripped off the public_html part of the path.
/var/www/my-domain.com/public/index.php” is not found
here is my site config file:
server {
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
# include snippets/snakeoil.conf
root /var/www/my-domain.com/public_html/public;
# Add index.php to the list if you are using PHP
index index.php;
charset utf-8;
server_name my-domain.com www.my-domain.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $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;
# pass PHP scripts to FastCGI server
#
location ~ .php$ {
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_hide_header X-Powered-By;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /.(?!well-known).* {
deny all;
}
access_log /var/log/nginx/my-domain.com.access.log;
error_log /var/log/nginx/my-domain.com.error_log;
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/my-domain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/my-domain.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.my-domain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = my-domain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name my-domain.com www.my-domain.com;
return 404; # managed by Certbot
}
Any help is much appreciated as I’ve been at this too long