我在我的本地主机上的 nginx 上有一个 wordpress 副本。当我想用浏览器打开它时,浏览器只会下载一个 php 文件而不会打开网站。我的 /etc/nginx/nginx.conf 文件包含:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
index index.html index.htm;
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
问题是什么?
答案1
尝试改变这一行:
default_type application/octet-stream;
到default_type text/html;
可能是你的 php 脚本没有设置内容 MIME 类型并且它从 nginx 开始。