国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 網(wǎng)站 > Nginx > 正文

Nginx添加ngx-fancyindex模塊的方法

2024-08-30 12:25:01
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

為了安全起見,Nginx默認(rèn)是不允許列出整個(gè)目錄的,即當(dāng)訪問(wèn)一個(gè)不包含首頁(yè)的目錄時(shí)會(huì)返回 403 錯(cuò)誤,當(dāng)我們需要將服務(wù)器某一目錄列出索引以便下載,我們可以使用 autoindex 來(lái)實(shí)現(xiàn),但是 autoindex 模塊生成的索引非常簡(jiǎn)陋,我們可以使用 ngx-fancyindex 代替 autoindex 實(shí)現(xiàn)索引目錄美化。

本文為已安裝 Nginx 環(huán)境下的操作。

安裝ngx-fancyindex

第一步

查看已安裝的 Nginx 版本與模塊信息:

nginx -V

輸出信息類似于:

nginx version: nginx/1.8.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --user=nginx --group=nginx

第二步

下載對(duì)應(yīng)版本的 Nginx 源碼包: http://nginx.org/download/

下載最新版本的 ngx-fancyindex 源碼包: https://github.com/aperezdc/ngx-fancyindex/releases

上傳至服務(wù)器并解壓,這里我們上傳到/tmp目錄。

第三步

編譯 Nginx

cd /tmp/nginx-1.8.0 #進(jìn)入源碼目錄 ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --user=nginx --group=nginx --add-module=../ngx-fancyindex-0.4.2make  #編譯

特別注意:

    ./configure后面的配置要對(duì)應(yīng)第一步的輸出信息,防止不必要的麻煩,–add-module=../ngx-fancyindex-0.4.2 這里根據(jù)你下載解壓后的 ngx-fancyindex 目錄名來(lái)。 只需要 make,不需要 install.

第四步

重命名舊的 nginx 文件:

mv /usr/local/nginx /usr/local/nginx.bak

復(fù)制重新編譯的nginx文件到nginx原來(lái)安裝目錄下:

cp ./objs/nginx /usr/local/nginx/sbin/

重新啟動(dòng) nginx 服務(wù):

service nginx restart

配置ngx-fancyindex

修改nginx配置文件

location /path/ #指定~/path目錄開啟自動(dòng)列目錄{ alias /alliot/path/; #虛擬目錄/alliot/path/開啟自動(dòng)列目錄 root /path/;  #實(shí)際目錄/path/開啟自動(dòng)列目錄 與alias二選一 fancyindex on;  #開啟nginx目錄瀏覽功能  fancyindex_exact_size off; #文件大小從KB開始顯示  fancyindex_localtime on; #顯示文件修改時(shí)間為服務(wù)器本地時(shí)間  fancyindex_footer "footer.html"; #設(shè)置footer為當(dāng)前目錄下的footer.html fancyindex_ignore "footer.html"; #設(shè)置不列出當(dāng)前目錄下的footer.html}

上面 alias 與 root 的區(qū)別在于, alias 指定的是當(dāng)前目錄,而 root 指定的是根目錄,一般情況下,建議在 “l(fā)ocation /” 中通過(guò)root命令來(lái)配置根目錄。

更多配置見 https://github.com/aperezdc/ngx-fancyindex

重載配置

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 南木林县| 稷山县| 玉田县| 鄂托克前旗| 哈巴河县| 平顶山市| 来安县| 浦县| 清流县| 苍梧县| 新化县| 中山市| 思南县| 灵川县| 临江市| 合水县| 晋州市| 南江县| 交城县| 延庆县| 玉田县| 长葛市| 囊谦县| 抚远县| 南康市| 荥经县| 石柱| 昔阳县| 许昌县| 呼玛县| 铁力市| 时尚| 巴马| 苍溪县| 新乡市| 竹北市| 多伦县| 柘城县| 色达县| 色达县| 新郑市|