配置系统服务前价差了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.
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
只时候可能是之前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)