Centos7 下nginx 搭建文件图片服务器

现在服务器部署nginx

yum  install -y epel-release
yum install nginx -y
安装完成之后
访问ip

image.png

由此可见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
image.png

访问图片
image.png
至此图片服务部署完成

微信公众号:[Kubernetes中文社区]
关注容器技术、关注Kubernetes。每天技术文章分享。
回复关键字视频Kubernetesdocker、获取视频学习资料
qrcode

猜你喜欢

转载自www.cnblogs.com/daydev/p/11207719.html