404 Not Found nginx/1.14.2 after upgrade PHP 8 on Azure - Laravel
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
Resolving the "404 Not Found - nginx/1.14.2" Error After PHP 8 Upgrade on Azure
Upgrading core components like PHP on a managed platform like Azure App Service is often smoother than managing a self-hosted environment, but it frequently introduces subtle configuration conflicts. Dealing with an intermittent 404 Not Found - nginx/1.14.2 error after moving from PHP 7.4 to PHP 8 on Linux environments requires a deep dive into the interaction between NGINX and the PHP FastCGI Process Manager (FPM).
As senior developers, we understand that these errors rarely stem from a simple syntax mistake; they usually point to a breakdown in the communication pipeline or an outdated rewrite rule. This post will walk you through the likely causes and provide robust solutions for stabilizing your Laravel application running on Azure using PHP 8.
Understanding the Root Cause: NGINX and PHP Version Mismatch
The error message 404 Not Found - nginx/1.14.2 indicates that NGINX is successfully receiving the request but cannot correctly map the requested path to the appropriate backend handler (PHP-FPM), resulting in a default 404 response instead of processing the file.
When you upgrade PHP, even if the core application code remains the same, the changes in how PHP handles routing, file permissions, and FastCGI communication can expose pre-existing subtle issues in your NGINX configuration. The guide you referenced (https://azureossd.github.io/2021/09/02/php-8-rewrite-rule/index.html) addresses the necessary rewrite rules for PHP 8, but if the issue persists, it suggests a deeper problem with how the try_files directive interacts with the new PHP environment setup on Azure.
Debugging and Stabilizing the NGINX Configuration
Your provided NGINX configuration looks fundamentally correct for handling .php files:
location / {
index index.php index.html index.htm hostingstart.html;
try_files $uri $uri/ /index.php?$args;
}
# ... FastCGI block follows
The key area for troubleshooting is the try_files directive and the subsequent FastCGI setup. When PHP 8 introduces stricter path handling, minor discrepancies often cause this failure.
Step 1: Verify PHP-FPM Health on Azure
Before touching NGINX, ensure that PHP-FPM itself is running correctly under the new PHP 8 environment. Check the status of your FPM service within the Azure App Service diagnostics. If PHP-FPM is crashing or failing to start, NGINX will naturally fail its request routing.
Step 2: Refine the FastCGI Block for Stability
While your existing setup is functional, we can make it more explicit and robust, especially in environments where path handling might be sensitive. Ensure that the variables passed to fastcgi_param accurately reflect the document root and script name.
Here is a slightly refined version focusing on clarity and ensuring correct FastCGI parameters:
server {
listen 8080;
listen [::]:8080;
root /home/site/wwwroot; # Ensure this path matches your application root
index index.php index.html index.htm;
server_name example.com www.example.com;
location / {
# This is the core routing logic
try_files $uri $uri/ /index.php?$args;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /html/;
}
# ... other location blocks remain as they are ...
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
fastcgi_pass 127.0.0.1:9000; # Ensure this port is correct for PHP-FPM on Azure
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
# ... rest of FastCGI settings ...
}
}
Step 3: Check Azure Environment Variables
Sometimes, the issue lies outside the NGINX configuration and within how the Azure environment passes variables to the container. Ensure that any custom environment variables related to PHP paths or FPM sockets are correctly configured for your App Service plan. For modern Laravel deployments, ensuring all service dependencies are correctly initialized is crucial, similar to best practices found on sites like laravelcompany.com.
Conclusion
The intermittent nature of the 404 Not Found error after a PHP upgrade strongly suggests a communication failure between NGINX and PHP-FPM, rather than a fundamental code error in your Laravel application itself. By meticulously checking the FastCGI directives within your NGINX configuration, verifying the health of the PHP service on Azure, and ensuring robust path handling, you can stabilize this setup. Remember that managing web server configurations is an iterative process; always test changes incrementally to pinpoint exactly where the failure point occurs.