zoukankan      html  css  js  c++  java
  • 阿里云服务器(ECS)Ubuntu中nginx配置不生效,页面一直是默认页面welcome to nginx

    ubuntu下nginx的配置文件所在目录:

    /etc/nginx

    我的问题是 监听80端口;
    如果是其他的端口就是OK的,只要一切换到80端口,就自动是默认页面welcome to nginx

    我们对nginx的配置主要写在nginx.conf文件里,这个目录下还有conf.d和sites-enabled两个文件夹,里面为默认的配置文件。
    相应的,在配置nginx,编辑nginx.conf文件时,需要把这两行注释掉,否则nginx.conf不会生效


    server{
            listen 80;
            server_name  dev.lixingjiaoyu.com;
            location / {
                root /usr/local/presbyter/server/build;
                try_files $uri $uri/ @router;
                index index.html;
            }
            location @router {
                rewrite ^.*$ /index.html last;
            }
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
        }

    配置完毕后,检查配置文件是否正确:

    sudo nginx -t 

    重启nginx使配置生效: 

    sudo nginx -s reload
    

      

    如果不成功,或者若出现以下错误:

     nginx:[error] open() "/run/nginx.pid" failed (2: No such file or directory)
    

      

    使用以下命令即可解决:

    nginx -c /etc/nginx/nginx.conf
    nginx -s reload
    

      

  • 相关阅读:
    第12组(78) 团队展示(组长)
    第一次结对编程作业
    Alpha冲刺总结
    第02组Alpha冲刺(6/6)
    第02组Alpha冲刺(5/6)
    第02组Alpha冲刺(4/6)
    第02组Alpha冲刺(3/6)
    第02组Alpha冲刺(2/6)
    第02组Alpha冲刺(1/6)
    第02组(51)需求分析报告
  • 原文地址:https://www.cnblogs.com/chenyablog/p/14957810.html
Copyright © 2011-2022 走看看