Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Job for nginx.service failed because the control process exited with error code [closed]

Tags:

nginx

centos7

I follow the steps to setup a nginx server. After I create example.com.config and symbolic link for each server block in the sites-enabled directory. My nginx can't start.

I can't restart nginx service. It shows the following message when I entered

$sudo systemctl restart 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.

$sudo systemctl status nginx.service -l shows the following message.

● nginx.service - nginx - high performance web server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2017-06-05 04:26:05 EDT; 1min 27s ago
     Docs: http://nginx.org/en/docs/
  Process: 4776 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)
  Process: 11491 ExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.conf (code=exited, status=1/FAILURE)

Jun 05 04:26:05 localhost.localdomain systemd[1]: Starting nginx - high performance web server...
Jun 05 04:26:05 localhost.localdomain nginx[11491]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Jun 05 04:26:05 localhost.localdomain nginx[11491]: nginx: [emerg] open() "/var/run/nginx.pid" failed (13: Permission denied)
Jun 05 04:26:05 localhost.localdomain nginx[11491]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jun 05 04:26:05 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=1
Jun 05 04:26:05 localhost.localdomain systemd[1]: Failed to start nginx - high performance web server.
Jun 05 04:26:05 localhost.localdomain systemd[1]: Unit nginx.service entered failed state.
Jun 05 04:26:05 localhost.localdomain systemd[1]: nginx.service failed.

PS: I am running under CentOS 7 on virtualbox. Please help me. Thank you.

Here's the output when I run ls -lart /var/run/

total 56
dr-xr-xr-x. 17 root           root            233 Jun  2 05:37 ..
drwxr-xr-x.  2 root           root             60 Jun  6 01:21 tmpfiles.d
drwxr-xr-x.  3 root           root             60 Jun  6 01:21 log
drwxr-xr-x.  2 root           root             60 Jun  6 01:21 mount
drwxr-xr-x.  4 root           root            120 Jun  6 01:21 initramfs
prw-------.  1 root           root              0 Jun  6 01:21 dmeventd-server
prw-------.  1 root           root              0 Jun  6 01:21 dmeventd-client
drwx------.  2 root           root             80 Jun  6 01:21 lvm
-rw-r--r--.  1 root           root              4 Jun  6 01:21 lvmetad.pid
drwxr-xr-x.  2 root           root             60 Jun  6 01:21 sysconfig
drwxr-xr-x.  2 root           root             40 Jun  6 01:21 samba
drwxr-xr-x.  2 root           root             40 Jun  6 01:21 setrans
drwxrwxr-x.  2 root           root             40 Jun  6 01:21 netreport
drwxr-xr-x.  2 root           root             40 Jun  6 01:21 faillock
drwx------.  2 rpc            rpc              40 Jun  6 01:21 rpcbind
drwxr-xr-x.  2 root           root             40 Jun  6 01:21 ppp
drwxrwxr-x.  3 root           libstoragemgmt   60 Jun  6 01:21 lsm
drwxr-xr-x.  2 root           root             40 Jun  6 01:21 spice-vdagentd
drwxr-xr-x.  2 root           root             40 Jun  6 01:21 sepermit
drwxr-xr-x.  2 radvd          radvd            40 Jun  6 01:21 radvd
drwx--x---.  2 root           root             40 Jun  6 01:21 mdadm
drwxr-xr-x.  2 root           root             40 Jun  6 01:21 certmonger
drwx--x--x.  2 setroubleshoot setroubleshoot   40 Jun  6 01:21 setroubleshoot
-rw-r--r--.  1 root           root              4 Jun  6 01:21 auditd.pid
drwxr-xr-x.  2 root           root             60 Jun  6 01:21 dbus
srw-rw-rw-.  1 root           root              0 Jun  6 01:21 rpcbind.sock
drwxr-xr-x.  3 root           lp               80 Jun  6 01:21 cups
drwxr-xr-x.  2 avahi          avahi            80 Jun  6 01:21 avahi-daemon
-rw-------.  1 root           root             11 Jun  6 01:21 alsactl.pid
-rw-r--r--.  1 root           root              4 Jun  6 01:21 chronyd.pid
-rw-r--r--.  1 root           root              4 Jun  6 01:21 ksmtune.pid
drwxr-xr-x.  2 root           root            100 Jun  6 01:21 abrt
-rw-------.  1 root           root              4 Jun  6 01:21 gssproxy.pid
srw-rw-rw-.  1 root           root              0 Jun  6 01:21 gssproxy.sock
-rw-------.  1 root           root              0 Jun  6 01:21 xtables.lock
drwxr-x---.  2 root           root             40 Jun  6 01:21 firewalld
-rw-r--r--.  1 root           root              4 Jun  6 01:21 dhclient-enp0s3.pid
drwxr-xr-x.  2 root           root             80 Jun  6 01:21 NetworkManager
-rw-------.  1 root           root              5 Jun  6 01:21 sm-notify.pid
drwxr-xr-x.  7 root           root            180 Jun  6 01:21 lock
-rw-------.  1 root           root              5 Jun  6 01:21 syslogd.pid
-rw-r--r--.  1 root           root              5 Jun  6 01:21 sshd.pid
-rw-r--r--.  1 root           root              5 Jun  6 01:21 crond.pid
-rw-r--r--.  1 root           root              5 Jun  6 01:21 atd.pid
-rw-r--r--.  1 root           root              4 Jun  6 01:21 libvirtd.pid
----------.  1 root           root              0 Jun  6 01:21 cron.reboot
drwxr-xr-x.  2 root           root             60 Jun  6 01:21 tuned
drwxr-xr-x.  6 root           root            220 Jun  6 01:21 libvirt
drwxr-xr-x.  2 root           root             40 Jun  6 01:21 plymouth
drwx------.  2 root           root             40 Jun  6 01:22 udisks2
drwxr-xr-x.  2 root           root             80 Jun  6 01:24 console
drwx--x--x.  4 root           gdm             120 Jun  6 01:24 gdm
drwxr-xr-x.  3 root           root             60 Jun  6 01:24 user
-rw-rw-r--.  1 root           utmp           1536 Jun  6 01:24 utmp
drwxr-xr-x.  7 root           root            160 Jun  6 01:24 udev
drwxr-xr-x. 17 root           root            420 Jun  6 01:25 systemd
drwxr-xr-x. 37 root           root           1140 Jun  6 01:25 .

ps -eaf |grep nginx

root       698   685  0 01:21 ?        00:00:00 runsv nginx
root       748   698  0 01:21 ?        00:00:00 svlogd -tt /var/log/gitlab/ngin
root       749   698  0 01:21 ?        00:00:00 nginx: master process /opt/gitlab/embedded/sbin/nginx -p /var/opt/gitlab/nginx
gitlab-+   800   749  0 01:21 ?        00:00:00 nginx: worker process
gitlab-+   801   749  0 01:21 ?        00:00:00 nginx: cache manager process
yen       6683  3840  0 01:44 pts/0    00:00:00 grep --color=auto nginx

Output of ps -eaf |grep nginx and netstat -tulpn |grep 80 before and after.

Here's the output of ps -eaf |grep nginx

root       669     1  0 21:50 ?        00:00:00 runsvdir -P /opt/gitlab/service log: svlogd: warning: unable to lock directory: /var/log/gitlab/nginx: temporary failure svlogd: fatal: no functional log directories. svlogd: warning: unable to lock directory: /var/log/gitlab/nginx: temporary failure svlogd: fatal: no functional log directories. svlogd: warning: unable to lock directory: /var/log/gitlab/nginx: temporary failure svlogd: fatal: no functional log directories. .....
root      4333   669  0 21:57 ?        00:00:00 runsv nginx
root      4348  4333  0 21:57 ?        00:00:00 svlogd -tt /var/log/gitlab/nginx
root      4374  4333  0 21:57 ?        00:00:00 nginx: master process /opt/gitlab/embedded/sbin/nginx -p /var/opt/gitlab/nginx
gitlab-+  4381  4374  0 21:57 ?        00:00:00 nginx: worker process
gitlab-+  4382  4374  0 21:57 ?        00:00:00 nginx: cache manager process
yen      14156  4094  0 23:13 pts/0    00:00:00 grep --color=auto nginx
like image 286
yen ng Avatar asked Jun 05 '17 08:06

yen ng


1 Answers

Check your error log with sudo cat /var/log/nginx/error.log|less You can also with WinScp by entering the path /var/log/nginx/

In my case had the syntax error. In my server configuration file I had: server_name {api.mydomain.com};

The correct is: server_name api.mydomain.com;

like image 142
Cristian Avatar answered Sep 27 '22 21:09

Cristian