我在 Windows 7(64 位)、PHP 5.4.12 和 Nginx 1.5.8 上运行。
我已经阅读了许多有关设置和解决此问题的教程,即当从本地主机请求 PHP 文件时,它将其作为文件下载,而不是显示 PHP 页面。下面是我的 nginx.conf 文件:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8081;
server_name localhost;
access_log C:/nginx/logs/access.log;
error_log C:/nginx/logs/error.log;
root C:/nginx/html;
fastcgi_param REDIRECT_STATUS 200;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
我通过命令提示符手动运行 nginx.exe。
我还尝试首先在单独的命令提示符处手动启动 php-cgi.exe,如下所示:
C:\php5.4.12\php-cgi.exe -b 127.0.0.1:9000
我请求的 php 文件位于 C:/nginx/html 内,我请求它为:
http://localhost:8081/info.php
它会下载它。该 PHP 文件的内容是:
<?php
phpinfo();
?>
我怎样才能让我的 PHP 脚本在这个环境中运行。有人有这方面的经验吗?
尝试改变default_type application/octet-stream;
to default_type text/html;
也许你的 php 脚本没有设置内容 MIME 类型,它来自 nginx。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)