3分钟教你快速搭建NGINX文件图片服务器

2022-11-21 21:11:45 浏览数 (1)

安装nginx

最快直接使用yum进行安装

代码语言:javascript复制
[root@localhost ~]# yum -y install epel-release
[root@localhost ~]# yum -y install nginx

创建存放文件/图片的目录

代码语言:javascript复制
[root@localhost ~]# mkdir -p /data/file

导入图片

代码语言:javascript复制
[root@localhost file]# ls
csdn.jpg  csdn.txt

修改nginx配置文件

代码语言:javascript复制
[root@localhost ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@localhost ~]# vi /etc/nginx/nginx.conf

启动nginx

代码语言:javascript复制
[root@localhost ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@localhost ~]# nginx
[root@localhost ~]# nginx -s reload

关闭防火墙、测试访问

代码语言:javascript复制
[root@localhost ~]# systemctl stop firewalld

curl:http://192.168.1.40/file/

0 人点赞