簡體   English   中英

404 Not Found nginx/1.14.2 after upgrade PHP 8 在 Azure - Laravel

[英]404 Not Found nginx/1.14.2 after upgrade PHP 8 on Azure - Laravel

我正在嘗試在 Azure App Service (Linux) 上從 PHP 7.4 升級到 PHP 8。

它顯示以下錯誤:404 Not Found - nginx/1.14.2

我知道問題是 PHP 8 中的 Azure 使用 NGINX 而不是 ZE9713ZAE034A02A827946F 所以我按照這里給出的步驟: https://azureossd.github.io/2021/09/02/php-8-rewrite-rule/index.ZFC35FDC70D5FC69D2698Z83A23

有一段時間它工作正常,但從它停止工作並重新啟動后的第二天開始顯示錯誤“404 Not Found nginx/1.14.2”

這是我的默認文件:

server {
    #proxy_cache cache;
    #proxy_cache_valid 200 1s;
    listen 8080;
    listen [::]:8080;
    root /home/site/wwwroot;
    index  index.php index.html index.htm;
    server_name  example.com www.example.com; 

    location / {            
        index  index.php index.html index.htm hostingstart.html;
        try_files $uri $uri/ /index.php?$args;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /html/;
    }
    
    # Disable .git directory
    #
    location ~ /\.git {
        deny all;
        access_log off;
        log_not_found off;
    }

    # Add locations of phpmyadmin here.
    #
    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
        fastcgi_pass 127.0.0.1:9000;
        include fastcgi_params;
        fastcgi_param HTTP_PROXY "";
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_intercept_errors on;
        fastcgi_connect_timeout         300; 
        fastcgi_send_timeout           3600; 
        fastcgi_read_timeout           3600;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 4 256k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
    }
}

這是安裝了 ssl 的有效 nginx 配置。 您可以將其視為參考並根據自己的需要進行修改

    server {
    server_name something.com www.something.com;
    root /var/www/something.com/public;
    
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

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

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/something.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/something.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}

server {
    if ($host = www.something.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = something.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    server_name something.com www.something.com;
    return 404; # managed by Certbot

}

我在 Azure App Services 中從 Apache 更改為 Nginx 時遇到了類似的問題。 我做了一些進一步的研究以使我的應用程序正常工作,並在https://www.azurephp.dev/2021/09/php-8-on-azure-app-service/上發布了有關它的博客。 也許我找到的解決方案可以進一步幫助您。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM