#配置Nginx动静分离,定义的静态页面直接从Nginx发布目录读取。
location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css|mp4|mp3|avi)$
{
root /web/www;
#expires定义用户浏览器缓存的时间为7天,如果静态页面不常更新,可以设置更长,这样可以节省带宽和缓解服务器的压力
expires 7d;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
location ~ \.php$ {
proxy_pass http://127.0.0.1:8080;
}
修改后可以先检查一下配置文件是否有错误
./nginx -t -c $PATH; $PATH 是nginx配置文件的绝对路径, 如果不用 -c路径参数, 默认是 /usr/local/nginx/conf/nginx.conf
然后重新加载配置文件
./nginx -s -c $PATH reload;