Failed to start The nginx HTTP and reverse proxy server issue

34,926

In my case, it was because port 80 has been taken.

sudo lsof -t -i:80
sudo kill [port in reply]
Share:
34,926
Manikandan S
Author by

Manikandan S

Web developer

Updated on December 01, 2022

Comments

  • Manikandan S
    Manikandan S over 1 year

    First time I'm stalling nginx server in my fedora 24. I'm using apache server for development. For onlyoffice integration I have to install nginx server. I installed nginx server by using this command dnf install nginx

    Before starting nginx server I stopped apache and disabled it also like below.

    systemctl stop httpd
    systemctl disable httpd
    

    If I start the nginx server sudo service nginx start I'm getting below error.

    Redirecting to /bin/systemctl start  nginx.service
    Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
    

    So I ran the systemctl status nginx.service command to know issue detail, I got below output in my terminal.

    [root@localhost ~]# systemctl -l status nginx.service
    ● nginx.service - The nginx HTTP and reverse proxy server
       Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
       Active: failed (Result: exit-code) since Thu 2016-10-20 01:45:57 IST; 10s ago
      Process: 10719 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)
      Process: 10709 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
    
    Oct 20 01:45:57 localhost.localdomain systemd[1]: Starting The nginx HTTP and reverse proxy server...
    Oct 20 01:45:57 localhost.localdomain nginx[10719]: nginx: [emerg] no port in upstream "php-fpm" in /etc/nginx/default.d/phpMyAdmin.conf:17
    Oct 20 01:45:57 localhost.localdomain nginx[10719]: nginx: configuration file /etc/nginx/nginx.conf test failed
    Oct 20 01:45:57 localhost.localdomain systemd[1]: nginx.service: Control process exited, code=exited status=1
    Oct 20 01:45:57 localhost.localdomain systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
    Oct 20 01:45:57 localhost.localdomain systemd[1]: nginx.service: Unit entered failed state.
    Oct 20 01:45:57 localhost.localdomain systemd[1]: nginx.service: Failed with result 'exit-code'.
    

    I tried several ways to fix by changing the listen 80 to listen 801 in /etc/nginx/nginx.conf but no issue. I followed the below urls also but I can't fix the issue.

    nginx not started and can't start

    https://serverfault.com/questions/717752/cant-start-nginx-code-exited-status-1-failure

    /etc/nginx/default.d/phpMyAdmin.conf

    # phpMyAdmin
    
    location = /phpMyAdmin {
        alias /usr/share/phpMyAdmin/;
    }
    
    location /phpMyAdmin/ {
         root /usr/share;
         index index.php index.html;
    
         location ~ ^/phpMyAdmin/(.+\.php)$
         {
             try_files $uri =404;
             fastcgi_intercept_errors on;
             include        fastcgi_params;
             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
             fastcgi_pass   php-fpm;  //this is line number 17
         }
    }
    

    Thanks in advance.