阿里雲配置ngxin,為靜態伺服器
阿新 • • 發佈:2018-12-14
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 { } }