【发布时间】:2012-05-10 17:54:42
【问题描述】:
很难在 nginx 配置中找出位置块。这就是我所拥有的:
server {
listen 80;
server_name _;
access_log /var/log/nginx/example.com.access_log;
error_log /var/log/nginx/example.com.error_log warn;
root /var/www/root;
index index.php index.htm index.html;
fastcgi_index index.php;
location /wp/ {
root /var/www/wordpress;
index index.php index.htm index.html;
fastcgi_index index.php;
}
location ~* \.php$ {
try_files $uri =404;
keepalive_timeout 0;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}
浏览到 / 按预期工作,并在 /var/www/root 中显示网站,但如果位置正常,我认为他们应该浏览到 /wp 应该将我带到 /var/www/wordpress 中的 wordpress 安装。我得到的只是:
404 未找到
nginx/0.7.67
如果我将 /var/www/wordpress 目录重新定位到 /var/www/root/wordpress 并浏览到 /wordpress,一切都完美了。
我对位置块做错了什么??
我以前从未配置过 nginx,反正我是一个完整的网络新手。
我也希望能够为其他应用程序提供更多位置块。这实际上只是在此处发布的一个基本示例。
将 nginx 更新为 Debian Squeeze backports 中的版本。没有改善:
404 未找到
nginx/1.1.19
【问题讨论】:
-
您是否尝试过转到 /wp/?
-
你不想想象 nginx/0.7.67 已经过时了。
-
我也试过 /wp/ 。这是来自 Debian 6 存储库的 nginx。我猜 Debian 确实有点落后。不过,我倾向于坚持使用 repos 中的内容。
-
您可以从 the backports repo 获得 Squeeze 的最新版本。
-
我会尝试更新并回帖。
标签: configuration nginx