安装 nginx
sudo apt-get install nginx
配置 nginx.conf
sudo nano /etc/nginx/nginx.conf
在http字段里面添加下面代码
server{
listen 8081; # 端口
server_name localhost; # 服务名
location / { # 访问地址
autoindex on; # 开启索引功能
autoindex_exact_size off; # 关闭计算文件确切大小
autoindex_localtime on; # 显示本机时间而非 GMT 时间
root 文件目录绝对路径; # 显示的根索引目录
}
}
设置权限
chmod 777 文件目录绝对路径 -R
重载配置
sudo /etc/init.d/nginx reload