美文网首页
六、nginx、http-server本地启动静态资源

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

作者: 懒羊羊3号 | 来源:发表于2019-03-02 10:22 被阅读0次

    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  //全局安装用绝对路径
    

    相关文章

      网友评论

          本文标题:六、nginx、http-server本地启动静态资源

          本文链接:https://www.haomeiwen.com/subject/fmuhyqtx.html