[英]NGINX/PHP downloading instead of executing
I have an NGINX server with fastcgi/PHP running on it. 我有一个运行fastcgi / PHP的NGINX服务器。 I need to add userdirs to it, but I can't get PHP to execute the files - it just asks me if I want to download it.
我需要添加用户名,但我无法让PHP执行文件 - 它只是问我是否要下载它。 It does work without the userdir (eg it works on physibots.info/hugs.php, but not physibots.info/~kisses/hugs.php).
它在没有userdir的情况下工作(例如,它适用于physibots.info/hugs.php,但不适用于physibots.info/~kisses/hugs.php)。
Config: 配置:
server {
listen 80;
server_name physibots.info;
access_log /home/virtual/physibots.info/logs/access.log;
root /home/virtual/physibots.info/public_html;
location ~ ^/~(.+?)(/.*)?\.php$ {
fastcgi_param SCRIPT_FILENAME /home/$1/public_html$fastcgi_script_name;
fastcgi_pass unix:/tmp/php.socket;
}
location ~ ^/~(.+?)(/.*)?$ {
alias /home/$1/public_html$2;
autoindex on;
}
location ~ \.php$ {
try_files $uri /error.html/$uri?null;
fastcgi_pass unix:/tmp/php.socket;
}
}
I've had a similar problem before on another server. 我之前在另一台服务器上遇到过类似的问题。 My issue was that the scripts containerd
<?
我的问题是脚本容器
<?
. 。 Taking all of that and placing php after it (like this
<?php
) anywhere it appears in the script executed the files instead of downloading them. 把所有这些都放在它后面(就像这个
<?php
)在脚本中出现的任何地方执行文件而不是下载它们。
Hope that helps. 希望有所帮助。
Try adding this line to the php location blocks: 尝试将此行添加到php位置块:
fastcgi_param REDIRECT_STATUS 200;
Btw - did you check that the php.socket
actually exists? 顺便说一句 - 你检查
php.socket
实际存在吗?
It turns out that it was linking to /home/foo/public_html/~foo. 事实证明,它链接到/ home / foo / public_html / ~foo。 So, a circular symlink from /home/foo/public_html/~foo back to /home/foo/public_html works like a charm.
所以,从/ home / foo / public_html / ~foo回到/ home / foo / public_html的循环符号链接就像一个魅力。 Thanks for all your help!
感谢你的帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.