簡體   English   中英

NGINX 只執行“index.php”而不執行任何其他“*.php”文件

[英]NGINX only executing “index.php” but not any other “*.php” files

我正在嘗試設置一個 CMS 來運行它的安裝。 安裝文件是一個安裝文件夾和一個名為“setup.php”的文件。 如果我在“example.com/setup.php”訪問我的網站,它會嘗試下載文件,但如果我將“setup.php”重命名為“index.php”並導航到“example.com/index.php”或只是“example.com”,它執行 php 文件。

我的站點的 nginx 配置是這樣的:

server {
    root /var/www/example.com;
    index  index.php index.html index.htm;
    server_name  example.com;

    listen [::]:443 ssl; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.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

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

    # Pass the PHP scripts to FastCGI server
    location ~ ^/index.php {
        # Write your FPM configuration here
        include snippets/fastcgi-php.conf;
        #fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php-fpm.sock;
        #fastcgi_index index.php;
        #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #include fastcgi_params;
    }

    # Whitelist
    ## Let TastyIgniter handle if static file does not exists
    location ~ ^/favicon\.ico { try_files $uri /index.php; }
    location ~ ^/sitemap\.xml { try_files $uri /index.php; }
    location ~ ^/robots\.txt { try_files $uri /index.php; }
    location ~ ^/humans\.txt { try_files $uri /index.php; }

    ## Let nginx return 404 if static file does not exists
    location ~ ^/assets/media { try_files $uri 404; }
    location ~ ^/storage/temp/public { try_files $uri 404; }

    location ~ ^/app/.*/assets { try_files $uri 404; }
    location ~ ^/app/.*/actions/.*/assets { try_files $uri 404; }
    location ~ ^/app/.*/dashboardwidgets/.*/assets { try_files $uri 404; }
    location ~ ^/app/.*/formwidgets/.*/assets { try_files $uri 404; }
    location ~ ^/app/.*/widgets/.*/assets { try_files $uri 404; }

    location ~ ^/extensions/.*/.*/assets { try_files $uri 404; }
    location ~ ^/extensions/.*/.*/actions/.*/assets { try_files $uri 404; }
    location ~ ^/extensions/.*/.*/dashboardwidgets/.*/assets { try_files $uri 404; }
    location ~ ^/extensions/.*/.*/formwidgets/.*/assets { try_files $uri 404; }
    location ~ ^/extensions/.*/.*/widgets/.*/assets { try_files $uri 404; }

    location ~ ^/themes/.*/assets { try_files $uri 404; }

}


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

    listen 80;
    listen [::]:80;
    server_name  example.com;
    return 404; # managed by Certbot


}

出於安全原因,我在發布之前更改了配置中的 web 地址。 我非常困惑為什么這不起作用,好像 index.php 執行,all.php 文件應該。 任何幫助弄清楚這一點將不勝感激。

我是個白痴,度過了漫長的一天。

location ~ ^/index.php {

應該

location ~ /.php {

暫無
暫無

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

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