nginx静态资源服务器简单配置
在nginx的server中可以拥有多个location,但location 后面那部分不能一样。
进入nginx安装目录的conf目录下,修改nginx.conf文件,在一个server{}中添加 一个location 部分配置代码如下
root@ubuntu:/usr/local/nginx/conf# vi nginx.confserver {listen 80;server_name localhost;location / {root html;index index.html index.htm;}location /image/ {root /usr/local/myImage/; <--代表 image之前的目录autoindex on;}}
刷新nginx的配置,重启即可
root@ubuntu:/usr/local/nginx/sbin# ./nginx -s reloadroot@ubuntu:/usr/local/nginx/sbin#
严禁直接搬运。标明出处。