seeing 404 Not Found nginx/1.26.2 in wordpress appservice, how to fix?

Jency Jacob 0 Reputation points
2025-02-28T10:46:03.6866667+00:00

i have created an appservice - PHP

extracted Wordpress files to home/sites/wwwroot

added db details to wp-config

but seeing 404 Not Found


nginx/1.26.2
in browser

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,501 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sampath 1,420 Reputation points Microsoft External Staff
    2025-03-06T10:19:18.58+00:00

    Hello @Jency Jacob,

    The NGINX isn’t correctly serving WordPress site. This is caused by one of the following issues:

    • NGINX isn’t not installed WordPress in (/home/site/wwwroot).
    • Missing or incorrect configuration in default.conf.
    • PHP files are not being processed correctly by PHP-FPM.

    Here’s how to fix it:

    Update NGINX Configuration

    Connect to your App Service via SSH:

     https://yoursite.scm.azurewebsites.net/webssh/host
    

    Copy the existing NGINX config for editing:

     cp /etc/nginx/conf.d/default.conf /home/dev/default.conf
    

    Open /home/dev/default.conf in a text editor and replace its contents with:

        server {
    
            listen 80;
    
            server_name mysite.azurewebsites.net;
    
            root /home/site/wwwroot;
    
            index index.php index.html index.htm;
    
            location / {
    
                try_files $uri $uri/ /index.php?$args;
    
            }
            location ~ \.php$ {
    
                include fastcgi_params;
    
                fastcgi_pass 127.0.0.1:9000;
    
                fastcgi_index index.php;
    
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    
            }
    
            error_page 404 /index.php;
        }
    
    

    Apply the Configuration via a Startup Script

        nano /home/dev/startup.sh
    

    Add the following content:

        echo "Copying custom default.conf over to /etc/nginx/conf.d/default.conf"
    
        cp /home/dev/default.conf /etc/nginx/conf.d/default.conf
        nginx -s reload   
    
        chmod +x /home/dev/startup.sh
    

    Run the following command to reload NGINX with the new configuration:

    nginx -s reload
    

    Alternatively, restart the App Service from the Azure Portal.

    If you're still getting a 404 error, check for errors in the logs:

    For more details refer this DOC for NGINX’s configuration when using Wordpress on App Service.

    Hope this helps!

    If you found this answer helpful, please click Accept Answer and consider upvoting it /click yes.

    accept

    If you have any further questions, please click Comment.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.