Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

CarbonNanotubes's avatar

NGINX+PHP-FPM - Sub directory file not found

I have an application that I am trying to dockerize. The document root is /var/www/html within the NGINX container. index.php simply redirects to APPLICATION/application.php when trying to access APPLICATION/application.php I get a file not found error. I need to get this working the way it is as I cannot make any changes to the application.

Here is my conf file

server {
        listen 80;
        server_name localhost;
        root /var/www/html;

        location / {
                index index.php index.html;
        }

        location ~* \.php$ {
                fastcgi_pass    php:9000;
                fastcgi_index   index.php;
                include         fastcgi_params;
                fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param   PATH_INFO $fastcgi_path_info;
        }
}

After lots of searching online I found this and tried it but I just get a 404.

location /APPLICATION {
                root /;
                index index.php;
                try_files $uri $uri/ /index.php?$query_string;

                location ~ \.php$ {
                        fastcgi_pass    php:9000;
                        fastcgi_index   index.php;
                        include         fastcgi_params;
                        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        fastcgi_param   PATH_INFO $fastcgi_path_info;
                }
        }

I am not too familiar with php-fpm, I do use it but I found a pre-made nginx config for laravel which just works.

Any ideas?

0 likes
0 replies

Please or to participate in this conversation.