Centos7---nginx搭建简易的文件服务器
Nginx(发音同“engine X”)是异步框架的网页服务器,也可以用作反向代理、负载平衡器和HTTP缓存。该软件由俄罗斯程序员伊戈尔·赛索耶夫(Игорь Сысоев)开发并于2004年首次公开发布[8]。2011年成立同名公司以提供支持服务[9]。2019年3月11日,Nginx公司被F5网络公司以6.7亿美元收购[10]
具体步骤
一、配置nginx的yum仓库 (https://nginx.org/en/linux_packages.html#RHEL

1、yum install yum-utils #安装yum的工具包
2、cat >> /etc/yum.repos.d/nginx.repo <<EOF #设置yum存储库,创建名为nginx.repo 的文件
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
EOF
二、安装配置nginx,网页测试是否成功

1、yum install nginx #安装nginx
2、mkdir -p /upload/software #创建文件存放目录
3、cat >> /etc/nginx/conf.d/ngx.conf <<EOF #修改nginx的配置文件
server {
listen 80; #端口
server_name localhost; #域名
error_log /var/log/nginx/error.log notice; #报错日志位置
access_log /var/log/nginx/access.log main; #访问日志位置
root /upload/software; #文件存放目录
location / {
charset utf-8; #设置编码格式
autoindex on; #启用自动首页功能
autoindex_exact_size off; #文件大小自动换算
autoindex_localtime on; #按服务器时间显示文件时间
}
}
EOF
4、nginx -t #检查配置文件语法
5、#启动nginx设置开机自启
systemctl enable nginx
systemctl start nginx
6、#检查进程和端口
ps -ef | grep nginx
ss -tlnp | grep nginx
7、#创建文件,登录网页下载测试
touch /upload/software/{1..10}.txt
