所有。 我在nginx和php5-fpm中使用debian。我让网站功能齐全,然后安装Tor来创建和洋葱网站。我成功配置它以加载index.html但是,当我使用index.php时,Tor浏览器不显示页面。而是,Tor浏览器下载index.php。我不确定我需要做什么配置。我这样做的目的是为了学习。我不关心安全性或真正使用.onion网站。尽管没有搞清楚,但这让我感到很困扰。谢谢。
这是我在/ etc / nginx / sites-available /
中的服务器块配置server {
listen 127.0.0.1:80;
root /var/www/html/;
index index.php index.html index.htm;
server_name 4bgxjb2vkb7tvsgw.onion;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
root /var/www/html/;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
片段/ fastcgi的-php.conf:
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;
感谢您的帮助!
答案 0 :(得分:1)
尝试这样的事情:
location / {
try_files $uri $uri/ =404;
}
error_page 401 403 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
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;
}