Manikandan S
Manikandan S

Reputation: 922

Failed to start The nginx HTTP and reverse proxy server issue

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.

Upvotes: 6

Views: 62741

Answers (4)

bluetata
bluetata

Reputation: 654

I also encountered this issue, I had a different situation, I am sure port 80 isn't taken in my machine after I run this command: netstat -nplt.

After I closed Selinux service, the problem was resolved.

Temporarily close the Selinux service you should run the command below:

setenforce 0

Permanently disable this service:

vim /etc/selinux/config

Change item from `SELINUX=enforcing` to `SELINUX=disabled`

Upvotes: 1

Aaron T
Aaron T

Reputation: 480

If you've installed php-fpm, you should look for where the socket is running and alter this line fastcgi_pass php-fpm; //this is line number 17.

You should be able to find it in the listen line within the php-fpm pool's config file. E.g. in Ubuntu, you can find it at /etc/php/<version>/fpm/pool.d/www.conf.

You might be able to get clues on the config with: ps aux | grep php-fpm.

Upvotes: 0

Noah Han
Noah Han

Reputation: 141

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

sudo lsof -t -i:80
sudo kill [port in reply]

Upvotes: 6

Manikandan S
Manikandan S

Reputation: 922

Answer for my question as @mattdm suggested, I installed php-fpm and now it's started working.

sudo dnf install php-fpm

Upvotes: 0

Related Questions