nginx.service的作业失败,因为控制进程退出并显示错误代码

时间:2017-06-05 08:34:43

标签: nginx centos7

我按照setup a nginx server的步骤进行操作。在已启用站点的目录中为每个服务器块创建 example.com.config 和符号链接后。我的nginx无法启动。

我无法重启nginx服务。我输入

时显示以下消息

$ 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 <​​/ strong>显示以下消息。

● 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:我在virtualbox上运行CentOS 7。 请帮我。谢谢。

这是我运行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.

这是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

1 个答案:

答案 0 :(得分:0)

使用func updateSearchResults(for searchController: UISearchController) { guard let searchText = searchController.searchBar.text else { return } searchResult = locationNames.filter({$0.prefix(searchText.count) == searchText}) collectionView.reloadData() } 检查您的错误日志 您也可以通过输入路径 / var / log / nginx /

使用WinScp

在我的情况下出现语法错误。 在服务器配置文件中,我有:sudo cat /var/log/nginx/error.log|less

正确的是:server_name {api.mydomain.com};