编程技术分享平台

网站首页 > 技术教程 正文

在centos7使用nginx当作静态服务器发布文件目录

xnh888 2024-09-12 22:25:01 技术教程 30 ℃ 0 评论

一.添加Nginx存储库

sudo yum install epel-release

二.安装Nginx

sudo yum install nginx

三.启动nginx

sudo systemctl start nginx

四.验证

如果还没关闭防火墙请先关闭防火墙

//临时关闭

systemctl stop firewalld

//禁止开机启动systemctl disable firewalld

Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.

Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

https:/// -----------ip为服务器的ip

五.设置要设置成文件夹的目录

cd /etc/nginx

nano nginx.conf

添加:

location / {

root /usr/share/nginx/html; # 这里/usr/share/nginx/html 是nginx的默认发布目录,所以里面不能有localtion /

autoindex on;

autoindex_exact_size off;

autoindex_localtime on;

}

六.重启nginx

sudo systemctl enable nginx

七.验证

https:///<目录>

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表