在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Linux/ 關(guān)于nginx 配置二級域名問題

關(guān)于nginx 配置二級域名問題

server {
        listen 8088;

        server_name test.example.com;

        root /home/www/test_tec.example.com/upload;
        index index.html index.php;

        access_log log/test_tec_access.log;
        error_log log/test_tec_error.log;

        location / {
                include /home/www/test_tec.example.com/upload/*.conf;
                index index.html index.php;
        }

        location /wiki {
                alias /home/www/wiki.example.com/;
                index index.html index.php;
        }

        location ~ \.php {
                include ext/php.conf;
                include ext/cors.conf;
        }

        include ext/expired.conf;
}

請教一下nginx配置二級域名問題
之前l(fā)ocation /wiki 配置規(guī)則用的是 root 通過url訪問,總會在root后多加一句/wiki

看了一些教程,說用alias 可以避免這個問題,于是改成圖中這樣的規(guī)則,但是現(xiàn)在訪問該二級直接報錯
File not found.

error.log

2018/02/02 09:24:47 [error] 13644#0: *20723710 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 49.77.232.248, server: test.example.com, request: "GET /wiki/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "test.example.com:8088"

請問如何解決??

回答
編輯回答
墨染殤

如果某個location里要配置alias指令
請?jiān)诼窂胶竺婕由?/
比如

location /example/ {
    alias /path/to/exam/;
}

另外配置請貼文字,要打馬賽克用example替換。


基于樓主補(bǔ)充的日志
問題出在 location /wiki/
這個location使用了alias,但后面還有一個location ~ \.php,這樣先匹配wiki再匹配\.php,到\.php,環(huán)境還是server塊的root指令

解決辦法:
如果一個location里使用了alias,但又會匹配到其他location,需要把其他location的配置加到這個location里

location /wiki {
    alias /home/www/wiki.example.com/;
    index index.html index.php;
    location ~ \.php$ {
        include ext/php.conf;
        include ext/cors.conf;
        include fastcgi_params;                       
        fastcgi_param SCRIPT_FILENAME $request_filename;
    }
}
2017年10月31日 07:34
編輯回答
有點(diǎn)壞

把你的error.log貼出來看看,應(yīng)該會告訴你是哪個文件file not found了,還有路徑,這樣你就很容易找到問題在哪。

2017年7月29日 18:14