Nginx配置資源下載目錄

訪問個人博客nginx

以前在網上找 CentOs 的鏡像的時候,發現了阿里雲的這個鏡像源,速度蠻快的。今天也來搭建一個相似的站,使用 nginx 做爲資源下載服務器。shell

<!--more-->vim

圖片詳情:服務器

mark

安裝 Nginx

參考這篇教程的 Nginx 環境搭建部分測試

設置資源存儲路徑

一、 資源準備阿里雲

home 的用戶目錄下,創建文件夾,如 softs ,在 softs 目錄中放入文件內容。spa

修改配置文件

二、 修改 Nginx 配置文件code

vim conf/nginx.conf

添加 serverserver

server {
        listen       80;
        server_name  down.vcmq.com;
        #sendfile        on;
        location / {
            alias  /home/softs/;
            sendfile on;
            autoindex on;
            autoindex_exact_size off;
            autoindex_localtime on;
        }
}

alias 設置爲第一步中的資源目錄,我這裏是 /home/softs/教程

三、 訪問測試
將本機 hosts 指向服務器, 訪問地址 down.vcmq.com 顯示目錄列表

mark

注意不能是/root 目錄下的文件路徑 ,會顯示403無權限

相關文章
相關標籤/搜索