1. Nginx安装
- Ubuntu:
sudo apt-get install nginx
- Fedora、Centos:
sudo yum install nginx
- Manjaro:
sudo pacman -S nginx
2. 配置文件
- 查找Nginx配置文件:
sudo find / -name nginx.conf
- 一般存放在 /etc/nginx/nginx.conf
3. 修改配置文件
-
在 http 节点中添加以下代码
autoindex on; #开启索引功能 autoindex_exact_size off; # 关闭计算文件确切大小(单位bytes),只显示大概大小(单位kb、mb、gb) autoindex_localtime on; # 显示本机时间而非 GMT 时间 charset utf-8; # 避免中文乱码 server { listen 9999; #监听端口号 server_name localhost; #root /usr/share/nginx/html; root /home/evil/share; # 共享的文件目录 error_log /home/evil/share/log/error.log ; # 报错的文件目录 location / { } error_page 404 /404.html; location = /40x.html { }