nginx
1、启动 必须要root权限
sudo nginx
sudo nginx -s reload 重启
sudo nginx -s stop 关闭
sudo service nginx reload
2、html目录
直接输入
/usr/local/Cellar/nginx
3、nginx.config
/usr/local/etc/nginx
4、post请求显示405
location / {
# 绝对路径 pwd查看当前路径
root /Users/yangyangran/www/dist;
index index.html index.htm;
# 加这一句
error_page 405 =200 $uri;
}
5、react打包后到路由
location / {
try_files $uri /index.html;
}
6、本地静态文件路由
![](https://img.haomeiwen.com/i9562281/449f6816ef21d061.png)
![](https://img.haomeiwen.com/i9562281/33419bdc7967a043.png)
ant-pro的nginx方案 https://pro.ant.design/docs/deploy-cn
http://www.runoob.com/linux/nginx-install-setup.html
7、上传文件最大限制
client_max_body_size 100M;
http-server
npm i --save-dev http-server
http-server './dist' -p 9000 //全局安装用绝对路径
网友评论