【发布时间】:2017-02-20 23:23:23
【问题描述】:
我正在尝试将我的个人服务器从 apache 迁移到 nginx,但我无法让该位置正常工作。
我的服务器有几个应用程序,可以从根目录中获得一些 /something,例如 url.com/git url.com/mediaWiki、url.com/vnstat url.com/redmine
在 apache 中,每个应用都有一堆配置文件:
redmine.conf
<Location "/redmine">
Options none
Require all granted
PassengerEnabled On
RailsBaseURI /redmine
RailsEnv production
</Location>
vnstat_php.conf
Alias /vnstat /var/www/vnstat_php
<Directory /var/www/vnstat_php>
DirectoryIndex index.php
Require all granted
</Directory>
我正在尝试在 nginx 上复制它,但到目前为止我最好的尝试以一个奇怪的 url 结尾。我只管理在主 ngix 配置文件上编写的工作:
server {
listen 8123 default_server;
listen [::]:8123 default_server;
server_name _;
root /var/www/html;
location / {
}
location /vnstat/ {
root /var/www/vnstat_php/;
index index.php;
}
}
根页面运行正常,但 /vnstat 链接将我发送到
2017/02/20 11:37:19 [error] 27538#0: *1 "/var/www/vnstat_php/vnstat/index.php" is not found (2: No such file or directory), client: 177.92.59.216, server: _, request: "GET /vnstat/ HTTP/1.1", host: "url.com:8123"
它正在 /var/www/vnstat_php/ 内寻找一个 vnstat 目录,而不是以 root 身份使用它。谁能指出我正确的方向?
【问题讨论】:
-
你需要
alias而不是root。也许是like this。
标签: nginx nginx-location