Nginx Slim Error 404

Hi , People

I have many ways , many method to set nginx for work fine with slim.
But right now , I still got error 404.
Please help or suggest me ? sir

Many Thanks.
Pratchaya

######## This is my conf. 
server {
    # Port 80 will require Nginx to be started with root permissions
    # Depending on how you install Nginx to use port 80 you will need
    # to start the server with `sudo` ports about 1000 do not require
    # root privileges
    # listen      80;

    listen        80;
    server_name   api.xxx.work;

   
    root /var/www/site/api/public_html/;
    index index.php index.html index.htm;

    charset utf-8;
    client_max_body_size 100M;
    fastcgi_read_timeout 1800;

    # Represents the root of the domain
    # http://localhost:8000/[index.php]
    location / {
        # Matches URLS `$_GET['_url']`
        try_files $uri $uri/ /index.php?_url=$uri&$args;
    }

    # When the HTTP request does not match the above
    # and the file ends in .php
    location ~ [^/]\.php(/|$) {
        # try_files $uri =404;

        # Ubuntu and PHP7.0-fpm in socket mode
        # This path is dependent on the version of PHP install
        #fastcgi_pass  unix:/var/run/php/php7.0-fpm.sock;
	fastcgi_pass unix:/run/php-fpm/www.sock;

        # Alternatively you use PHP-FPM in TCP mode (Required on Windows)
        # You will need to configure FPM to listen on a standard port
        # https://www.nginx.com/resources/wiki/start/topics/examples/phpfastcgionwindows/
        # fastcgi_pass  127.0.0.1:9000;

        fastcgi_index /index.php;

        include fastcgi_params;
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        if (!-f $document_root$fastcgi_script_name) {
            return 404;
        }

        fastcgi_param PATH_INFO       $fastcgi_path_info;
        # fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        # and set php.ini cgi.fix_pathinfo=0

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~ /\.ht {
        deny all;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires       max; log_not_found off;
        access_log    off;
    }
}

PS. Only index.php ( normal code work fine )
Screen Shot 2564-01-30 at 18.19.04

Have you tried to use the Nginx example from the official documentation?

I don’t see a public/ directory with the index.php file.
Make sure you have a public/ directory and a public/index.php file.
Then configure the Nginx root /path/to/public;

Also change index index.php index.html index.htm; to
index index.php; as shown in the documentation.

Better take the example from the documentation and change it to your needs.

Hi , Odan

Following your suggestion , I still got error.
and I also attach screen capture about the folder, file structure for more information.

So , about nginx example with slim , I have already try before post in this board too.

Many Thanks
Please help.
Pratchaya

PS.

Your web server root should only contain index.php and css/js/image files, everything thing else is usually 1 folder up, you have everything in the root.

Generally speaking, you don’t want everyone publicly available.