【发布时间】:2014-10-24 19:25:12
【问题描述】:
我正在使用 Droplet (Digital Ocean) 安装网站。我在使用 PHP 正确安装 NGINX 时遇到问题。我做了一个教程https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-14-04 但是当我尝试运行一些 .php 文件时,它只是在下载它......
例如...http://5.101.99.123/info.php 它正在工作但是...如果我去主要的http://5.101.99.123 它正在下载我的 index.php :/
有什么想法吗?
-rw-r--r-- 1 agitar_user www-data 418 Jul 31 18:27 index.php
-rw-r--r-- 1 agitar_user www-data 21 Aug 31 11:20 info.php
我的 /etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/html;
index index.html index.htm index.php;
# Make site accessible from http://localhost/
server_name agitarycompartir.com;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
## NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location / {
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
...
其他“位置”已注释...
.
【问题讨论】:
-
是的...您没有正确设置带有 Nginx 的 PHP-FPM。这就是我们可以告诉您的全部内容,因为您没有向我们展示您的任何配置。
-
你想看哪个文件?谢谢@Brad
-
您将配置放入哪个文件(或多个文件)。相关部分是...您在 Nginx 配置中设置 PHP-FPM 的位置。
-
在谷歌搜索了一个小时后发现了这个askubuntu.com/a/601996/89455 - 如果您在尝试清除缓存之前配置错误 - 在这里工作!
-
在stackoverflow.com/q/42664080/287948查看 PHP7 的类似问题/答案
标签: php wordpress nginx location fastcgi