1、启动Nginx
//进入系统nginx的sbin目录
cd /usr/local/nginx/sbin
./nginx
2、停止Nginx
//进入系统nginx的sbin目录
cd /usr/local/nginx/sbin
./nginx -s stop
也可使用 kill停止进程
kill -9 nginx进程ID
3、重启Nginx
//进入系统nginx的sbin目录
cd /usr/local/nginx/sbin
./nginx -s reload
4、设置重定向
需要修改的文件是nginx.conf【一通常情况下在/usr/local/nginx/conf/nginx.conf】,在server中添加代码 location为重定向后的路径, {}中为原地址
server {
listen 8080;
server_name localhost;
location /aaa/bbb/ {
alias /ccc/ddd/eee/fff/;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
注:修改conf文件保存后要重启nginx!
5、设置请求大小【文件上传大小】
上传文件大小相关的有三个配置
* client_body_buffer_size 配置请求体缓存区大小, 不配的话,
* client_body_temp_path 设置临时文件存放路径。只有当上传的请求体超出缓存区大小时,才会写到临时文件中
* client_max_body_size 设置上传文件的最大值
通常情况修改 client_max_body_size 就可以解决请求413的问题
server {
listen 7980;
server_name localhost;
client_max_body_size 500M; *需要多大就把阈值改为多大
}
注:修改conf文件保存后要重启nginx!