我正在安装一个水滴(数字海洋)的网站。我有一个问题,安装NGINX与PHP正确。我做了一个教程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可用/默认
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
}
..。
其他的“位置”被评论...
。
发布于 2015-02-21 17:38:05
要在Nginx Server上执行php文件,需要将其添加到/etc/Nginx/sites enabled/default:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
发布于 2017-07-02 02:05:48
我也有同样的问题,但没有一个答案能解决这个问题。
我跑了一下:
sudo nginx -t
测试/etc/nginx/sites available/default中的配置文件。
它给了我这些错误:
nginx: [emerg] unexpected end of file, expecting "}" in /etc/nginx/sites-enabled/default:115
nginx: configuration file /etc/nginx/nginx.conf test failed
所以我进入了配置文件,在最后一行有
#}
我取消了注释,再次运行test命令,它起作用了
发布于 2017-11-22 07:35:30
对我来说,在/index.php的末尾添加?$query_string
很有帮助,如下所示:
location / {
try_files $uri $uri/ /index.php?$query_string;
}
https://stackoverflow.com/questions/25591040
复制相似问题