nginx.conf 配置
当我请求 http://192.168.0.1/uploadPath/j001/a.jpg
实际上找的是 /usr/local/source/uploadPath/j001/a.jpg
还有一点就是 务必保证 /usr/local/source/uploadPath 有权限
如果不确定 就执行命令 chmod -R 777 /user
因为每次需要创建新的文件夹 ,加上这句话可以赋予权限
Runtime.getRuntime().exec("chmod -R 777 " + uploadPath);
location /uploadPath/ {
root /usr/local/source/;
autoindex on;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location /uploadPath/ {
root /usr/local/source/;
autoindex on;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}