1. 程式人生 > >nginx作為靜態資源服務器的配置

nginx作為靜態資源服務器的配置

nginx 靜態資源

在http模塊添加:

server {
listen 80;
server_name localhost;
location /www/ {
root /data/;
index index.html index.htm;
}
location /image/ {
root /data/;
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

nginx作為靜態資源服務器的配置