CentOS上部署Nginx作为个人文件服务器
开机进入服务器:
yum -y update # 更新 reboot # 重启
部署Nginx:
yum -y install nginx # 安装nginx systemctl enable nginx # 设置自启动 systemctl start nginx # 启动nginx
# 这个时候我们可以直接访问服务器IP查看,出现Nginx默认页面即表示服务成功运行
配置Nginx:
vim /etc/nginx/nginx.conf # 编辑Nginx配置文件
# 按i键进入编辑模式:
# 在nginx.conf的http字段中添加如下内容:
http {
# 需要添加内容
autoindex on; # 显示目录
autoindex_exact_size on; # 显示文件大小
autoindex_localtime on; # 显示文件时间
}
# 在nginx.conf的server字段中添加如下内容:
server {
# 需要添加内容
charset utf-8; # 支持中文
}
# 按esc键退出编辑模式,输入:wq保存配置文件并退出编辑
应用Nginx更改:
systemctl restart nginx # 重启nginx服务,使配置生效
浙公网安备 33010602011771号