编程技术分享平台

网站首页 > 技术教程 正文

nginx设置目录浏览并支持中文(nginx显示目录文件)

xnh888 2024-10-03 04:35:58 技术教程 19 ℃ 0 评论



停止并禁用防火墙

systemctl stop firewalld.service    #停止firewalld
systemctl disable firewalld.service   #禁用firewalld

关闭SElinux功能

setenforce 0     # 临时关闭SElinux
getenforce     # 查看SElinux状态
#修改配置文件使其永远生效
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

编辑配置文件:vim /etc/nginx/conf.d/default.conf

 location /download {
        alias  /home/software/;    #指定目录所在路径,注意alias和后面的/
        autoindex on;    #开启目录浏览
        autoindex_format html;   #以html风格将目录展示在浏览器中
        autoindex_exact_size off; #切换为 off 后,以可读的方式显示文件大小,单位为 KB、MB 或者 GB
        autoindex_localtime on; #以服务器的文件时间作为显示的时间
        charset "utf-8,gbk"; #展示中文文件名
        }

相关命令

#启动nginx服务
systemctl start nginx.service 

#设置开机自启动
systemctl enable nginx.service
?
#停止开机自启动
systemctl disable nginx.service
?
#查看服务当前状态
systemctl status nginx.service
?
#重新启动服务
systemctl restart nginx.service 
?
#查看所有已启动的服务
systemctl list-units --type=service

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

欢迎 发表评论:

最近发表
标签列表