Simple Machines Community Forum

SMF Support => Server Performance and Configuration => Topic started by: Macostick on March 30, 2021, 12:10:00 AM

Title: 404 Not Found
Post by: Macostick on March 30, 2021, 12:10:00 AM
Good morning all !

I come asking for help because it's been a while that I block on a problem but I have not seen good answers anywhere.


With Debian 10, I installed NGINX 1.19.8

NGINX configuration:

server {
    listen 80 default_server;
    listen [::]:80 default_server;


    root /var/www/html;

    index index.html index.htm index.nginx-debian.html;

    server_name mywebsite.com;

    location / {

        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }

}



When I go on my link I see well: Welcome to nginx!

So I have UNZIP the simple archive machine forum in / var / www / html / but when I want to go to settings.php this shows me: 404 NOT FOUND

Does anyone know where can the problem come from?  :o

Thank you
Title: Re: 404 Not Found
Post by: Kindred on March 30, 2021, 10:04:50 AM
well, first of all -- you can not EVER access Settings.php directly

(also Linux is case sensitive settings.php is different from Settings.php)
Title: Re: 404 Not Found
Post by: m4z on March 30, 2021, 12:04:59 PM
Is your nginx setup for PHP? Other than f.e. apache, nginx can't handle FCGI (https://en.wikipedia.org/wiki/FastCGI) itself, so you need something like PHP-FPM (https://php-fpm.org/):

1). Install support for CGI:

apt install install php5-fpm


Edit: I'm not sure if php5 is still the default on D10 (try php7-fpm instead); these instructions are for D8.


2.) Then, nginx needs to use it (so it knows what to do with .php files). Create a file "/etc/nginx/conf.d/global/php.conf" (official docs (https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi/)):

location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        if (!-f $document_root$fastcgi_script_name) {
                return 404;
        }
        # Mitigate https://httpoxy.org/ vulnerabilities
        fastcgi_param HTTP_PROXY "";
        fastcgi_pass unix:/run/php5-fpm.sock;

        # include the fastcgi_param setting
        #include fastcgi_params;
        #
        # SCRIPT_FILENAME parameter is used for PHP FPM determining
        # the script name. It is not set in fastcgi_params, but
        # in fastcgi.conf
        include fastcgi.conf;
}


3.) Next, include this file from your vhost file (inside the "server" block):

include conf.d/global/*.conf;


4.) Reload nginx to verify everything works:

systemctl reload nginx


5.) Replace the "index [...]" line in your vhost (inside the "server" block) with:

index index.php;


6.) Reload nginx again to verify everything works:

systemctl reload nginx
Title: Re: 404 Not Found
Post by: Macostick on March 30, 2021, 07:43:39 PM
Thank you m4z I succeeded thanks to you  ;)