问题configurationnginx位置

使用nginx作为RedHat Enterprise主机上的Web服务器。

开始认为我不完全理解nginx.conf中的位置的使用,尽pipe例子和我读过的东西。

我原本只是为了维护我们的内部维基而设置的。

我试图改变的东西,但它可以承载其他的东西。

而不是让这个wiki出现在http://myserver.corp.com

我希望这个wiki出现在http://myserver.corp.com/wiki/

/ wiki不是服务器上的文件夹或存在,它应该只是将/ wiki的请求redirect到服务器上的另一个位置。

我在我的nginx.conf中更改了以下内容:

server { server_name myserver.corp.com; root /var/www/public_html/; index index.html index.php; autoindex off; location /wiki { root /usr/share/mediawiki123/; } location ~ \.php$ { include fastcgi.conf; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; } } 

但是,通过添加位置信息并尝试访问它,我在日志中看到以下内容:

2017/09/07 17:16:43 [错误] 614#0:* 1“/usr/share/mediawiki123/wiki/index.html”找不到(2:没有这样的文件或目录),客户端:10.13。 168.153,server:myserver.corp.com,请求:“GET / wiki / HTTP / 1.1”,主机:“myserver.corp.com”

它似乎是追加/维基到文件夹结构?

而不是试图访问:“/usr/share/mediawiki123/wiki/index.html”

它应该是:“/usr/share/mediawiki123/index.html”

你想在你的location块的alias ,而不是root 。 这两个指令如何构build资源path有一个微妙但重要的区别 。