Nginx下载php文件而不是执行

时间:2017-05-31 17:30:40

标签: php nginx configuration

我开始加载根域和类别或页面。但我无法登录/ admin /或/ phpmyadmin /而是下载application / octet-stream文件。

可以做些什么?感谢

这是我的conf文件:

server { 
listen 80; 
listen [::]:80;   #Use this to enable IPv6 
server_name localhost; 
root /var/www/html/;

index index.php;

location / {
try_files $uri $uri/ @rewriteapp; }

location @rewriteapp {
# rewrite all to index.php
rewrite ^(.*)$ /index.php/$1 last; }

# Php configuration location ~ ^/(index|index_dev)\.php(/|$) {
# Php-FPM Config (Socks or Network) 
fastcgi_pass unix:/run/php/php7.1-fpm.sock;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; }




# Security. discard all files and folders starting with a "." location ~ /\. {
deny  all;
access_log off;
log_not_found off; }
# Stuffs location = /favicon.ico {
allow all;
access_log off;
log_not_found off; } location ~ /robots.txt {
allow  all;
access_log off;
log_not_found off; }

# Static files location ~* ^.+\.(jpg|jpeg|gif|css|png|js|pdf|zip)$ {
expires     30d;
access_log  off;
log_not_found off; } 
}

1 个答案:

答案 0 :(得分:0)

我也有类似的问题

    location = /images/favicons/site.webmanifest {
    log_not_found off;
    access_log off;
}

它下载文件而不是仅显示

编辑:

我找到了可行的解决方案,但不知道最好的解决方案...

location = /images/favicons/site.webmanifest {
    default_type webmanifest;
    log_not_found off;
    access_log off;
}