配置nginx静态文件服务器

1.安装nginx
sudo apt-get install nginx

2.配置
安装完成后默认目录为/usr/share/nginx/html
配置文件/etc/nginx/sites-available/default
将配置修改为如下
server_name localhost;

location / {

# First attempt to serve request as file, then

# as directory, then fall back to displaying a 404.

root /usr/share/nginx/html/;

autoindex on;

}

3.删除/usr/share/nginx/html 中默认的index.html

4重启nginx
sudo service nginx restart

你可能感兴趣的:(配置nginx静态文件服务器)