Nginx 文件服務(wù)器配置

卸載

# 刪除除了配置文件以外的所有文件。
sudo apt-get remove nginx nginx-common
# 刪除所有與nginx有關(guān)的東西,包括配置文件。 
sudo apt-get purge nginx nginx-common 
# 在上面命令結(jié)束后執(zhí)行,主要是刪除與Nginx有關(guān)的且不再被使用的依賴包。
sudo apt-get autoremove 
# 刪除兩個(gè)主要的包。
sudo apt-get remove nginx-full nginx-common 

下載

nginx官網(wǎng):http://nginx.org/en/download.html
選擇穩(wěn)定的nginx版本下載。

安裝

# 安裝依賴
sudo apt-get install libpcre3 libpcre3-dev zlib1g-dev openssl libssl-dev gcc

# 配置
sudo ./configure

#編譯
sudo make

#安裝
sudo make instal

常用命令

# 啟動nginx的命令為:
/usr/local/nginx/sbin/nginx
停止nginx的命令為 :
# /usr/local/nginx/sbin/nginx -s stop
重啟nginx的命令為:
# /usr/local/nginx/sbin/nginx -s reload

配置文件服務(wù)器

# 1. 新建共享目錄
mkdir -p /home/${user}/nginx/data
# 2.修改配置文件
sudo vim /usr/local/nginx/conf/nginx.conf
# 3,配置
http {
        ...
        #顯示目錄
        autoindex on;

        # 顯示文件大小
        autoindex_exact_size on;

        # 顯示文件時(shí)間
        autoindex_localtime on;

        # 防止中文亂碼
        charset utf-8;


    server {
        listen       81;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

      location /download{ 
            alias /home/majin/share;
            allow all;
            autoindex on;
       }
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容