chenyablog

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

  

 

分类:

技术点:

相关文章:

  • 2021-11-09
  • 2021-05-20
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
猜你喜欢
  • 2022-01-09
  • 2021-07-10
  • 2021-12-12
  • 2022-12-23
  • 2022-01-10
相关资源
相似解决方案