ubutun 因为端口冲突引起安装nginx报错的解决方法

0. 错误状态

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
invoke-rc.d: initscript nginx, action "start" failed.
● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2018-06-08 17:21:27 CST; 7ms ago
  Process: 20300 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
  Process: 20295 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)


1. 问题分析

本机已经使用了80端口,与nginx默认端口冲突

2. 解决方法

  • 修改nginx配置文件
    • 打开 /etc/nginx/sites-available 的 default文件
      sudo cd /etc/nginx/sites-available
      sudo vim default
      
    • 修改default文件
      将其中的80换成不冲突的端口
          server {
          listen 80 default_server;
          listen [::]:80 default_server;
      
      
  • 重启nginx服务
 systemctl restart nginx.service

你可能感兴趣的:(ubutun 因为端口冲突引起安装nginx报错的解决方法)