gpt4 book ai didi

Nginx 尝试下载文件而不是显示

转载 作者:可可西里 更新时间:2023-11-01 13:22:57 25 4
gpt4 key购买 nike

我安装了 Nginx 并且有一个子域和域。子域有 php5-fpm 和 wordpress。它工作正常,并且在一个站点可用文件中,该文件符号链接(symbolic link)到启用站点。该域没有 php,并且有一个文件也有符号链接(symbolic link)。即使在我进入域时重新启动服务器后,它也会尝试下载 html 文件。这是我的域可用站点页面:

       server {
server_name www.example.us;
rewrite ^(.*) http://example.us$1 permanent;
}

server {
listen 80;
server_name example.us;
root /var/www/example;
index index.php;
autoindex on;
autoindex_exact_size off;
include /etc/nginx/security;
# Logging --
access_log /var/log/nginx/example.us.access.log;
error_log /var/log/nginx/example.us.error.log notice;
# serve static files directly
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
access_log off;
expires max;
}

# location ~ \.php$ {
# try_files $uri =404;
# fastcgi_pass unix:/var/run/php5-fpm/example.us.socket;
# fastcgi_index index.php;
# include /etc/nginx/fastcgi_params;
# }
}

nginx.conf 文件是:

user www-data; 
worker_processes 4;
pid /var/run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}
http {
# Basic Settings
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;
# Logging Settings
log_format gzip '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" "$gzip_ratio"';
access_log /var/log/nginx/access.log gzip buffer=32k;
error_log /var/log/nginx/error.log notice;
# Gzip Settings
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
# Virtual Host Configs
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

最佳答案

删除 default_type application/octet-stream;。这行让浏览器认为它是一些二进制数据而不是 HTML。

关于Nginx 尝试下载文件而不是显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16229026/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com