1. 程式人生 > >Centos7 下nginx 搭建檔案圖片伺服器

Centos7 下nginx 搭建檔案圖片伺服器

現在伺服器部署nginx

yum  install -y epel-release
yum install nginx -y
安裝完成之後
訪問ip

由此可見nginx服務是可用的
修改nginx的配置檔案如下
root@localhost conf.d]# pwd
/etc/nginx/conf.d
[root@localhost conf.d]# cat default.conf 
server {
    listen       80;
    server_name  localhost;
    root   /home/www;

    #access_log  /var/log/nginx/host.access.log  main;

    location / {
    autoindex on; # 索引
    autoindex_exact_size on; # 顯示檔案大小
    autoindex_localtime on; # 顯示檔案時間
    }
    #error_page  404              /404.html;
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}
[root@localhost conf.d]# 

修改root指向的位置
新增這三項

autoindex on; # 索引
autoindex_exact_size on; # 顯示檔案大小
autoindex_localtime on; # 顯示檔案時間

修改好配置之後 重啟nginx 服務

nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
nginx -s reload

在root指向目錄放入檔案
訪問ip

訪問圖片


至此圖片服務部署完成

微信公眾號:[Kubernetes中文社群]
關注容器技術、關注Kubernetes。每天技術文章分享。
回覆關鍵字視訊Kubernetesdocker、獲取視訊學習資料