1. 程式人生 > >使用nginx快速搭建檔案伺服器

使用nginx快速搭建檔案伺服器

準備工作:

關閉防火牆 systemctl stop firewalld && systemctl disable firewalld

禁用selinux setenforce 0 ----臨時關閉

                 sed -i "s/SELINUX=enforcing/SELINUX=Disabled/g" /etc/selinux/config

安裝nginx:

yum install nginx -y

  安裝完成後,驗證nginx頁面可以訪問

 

 

設定nginx檔案伺服器:

  首先需要檢視nginx是通過哪個配置檔案啟動

   nginx -h

 

 修改nginx配置檔案:

  vim /etc/nginx/nginx.conf 新增內容如下:

        root         /usr/share/nginx/html    #檔案存放的位置         autoindex on;                               #開啟索引功能          autoindex_exact_size off;  # 關閉計算檔案確切大小(單位bytes),只顯示大概大小(kb mb gb)         autoindex_localtime on;   # 顯示本機時間而非 GMT 時間

 

:wq 儲存並退出

重啟nginx 

systemctl restart nginx 

登陸ip:8080

顯示這個說明已經安裝成功了!!!