排障集合——Nginx和Apache设置系统服务systemctl start时报错,Job for nginx.service failed because the control process

配置系统服务前价差了nginx配置,无误。

[root@localhost system]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

**设置系统服务,使用systemctl启动时,启动服务失败,检查文件配置依旧无误。``**`
```csharp
[root@localhost system]# cd /lib/systemd/system
[root@localhost system]# vi nginx.service 
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/bin/kill -s HUP $MAINPID
ExecStop=/usr/bin/ki11 -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[root@localhost system]# systemctl start nginx   //无法开启,配置也无误
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
[root@localhost system]# systemctl status nginx.service    //查看状态也毫无所获
● nginx.service - nginx
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sat 2020-09-12 18:28:58 CST; 10s ago
  Process: 17948 ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=1/FAILURE)

Sep 12 18:28:55 localhost.localdomain nginx[17948]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address alr...use)
Sep 12 18:28:55 localhost.localdomain nginx[17948]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address alr...use)
Sep 12 18:28:56 localhost.localdomain nginx[17948]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address alr...use)
Sep 12 18:28:56 localhost.localdomain nginx[17948]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address alr...use)
Sep 12 18:28:57 localhost.localdomain nginx[17948]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address alr...use)
Sep 12 18:28:57 localhost.localdomain nginx[17948]: nginx: [emerg] still could not bind()
Sep 12 18:28:58 localhost.localdomain systemd[1]: nginx.service: control process exited, code=exited status=1
Sep 12 18:28:58 localhost.localdomain systemd[1]: Failed to start nginx.
Sep 12 18:28:58 localhost.localdomain systemd[1]: Unit nginx.service entered failed state.
Sep 12 18:28:58 localhost.localdomain systemd[1]: nginx.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

只时候可能是之前nginx服务已经启动了,我们只需要pkill杀死nginx的所有进程,重新systemctl start启动即可。

[root@localhost system]# pkill "nginx"   //杀死所有进程
[root@localhost system]# systemctl start nginx  //开启不报错了
[root@localhost system]# systemctl status nginx.service   //查看状态,确实成功开启了
● nginx.service - nginx
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: active (running) since Sat 2020-09-12 18:29:36 CST; 2s ago
  Process: 17973 ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=0/SUCCESS)

你可能感兴趣的:(排障集合,web服务器集群,linux,centos,nginx,apache)