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

一.添加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.


http://<ip>/ -----------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

    七.验证

    http://<ip>/<目录>

参考:https://blog.csdn.net/Post_Yuan/article/details/78603212

     https://www.jianshu.com/p/248d8e7cb3c4

猜你喜欢

转载自blog.csdn.net/weixin_36104843/article/details/80233994