六、nginx、http-server本地启动静态资源

2019-03-02  本文已影响0人  懒羊羊3号

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、本地静态文件路由


image.png
image.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  //全局安装用绝对路径
上一篇下一篇

猜你喜欢

热点阅读