I have an NGINX server with fastcgi/PHP running on it. 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. It does work without the userdir (eg it works on physibots.info/hugs.php, but not 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.
Hope that helps.
Try adding this line to the php location blocks:
fastcgi_param REDIRECT_STATUS 200;
Btw - did you check that the php.socket
actually exists?
It turns out that it was linking to /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. Thanks for all your help!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.