在http模块添加:
server { listen 80; server_name localhost; location /www/ { root /data/; index index.html index.htm; } location /image/ { autoindex on;
创建目录,拷贝文件
mkdir -p /data/www
mkdir /data/image
cp yellow.jpg /data/image
cp index.html /data/www
nginx -s reload
浏览器访问:
http://localhost/www/index.html
http://localhost/image/yellow.jpg