Linux编译和yum安装Nginx服务启动文件
Posted 白-胖-子
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux编译和yum安装Nginx服务启动文件相关的知识,希望对你有一定的参考价值。
编译安装nginx服务启动文件
[root@C8-189 ~]# systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vend>
Active: active (running) since Thu 2021-06-17 18:21:42 CST; 4min 45s>
Main PID: 8334 (nginx)
Tasks: 2 (limit: 11353)
Memory: 2.4M
CGroup: /system.slice/nginx.service
├─8334 nginx: master process /apps/nginx/sbin/nginx
└─8335 nginx: worker process
Jun 17 18:21:42 C8-189 systemd[1]: Starting The nginx HTTP and reverse >
Jun 17 18:21:42 C8-189 nginx[8331]: nginx: the configuration file /apps>
Jun 17 18:21:42 C8-189 nginx[8331]: nginx: configuration file /apps/ngi>
Jun 17 18:21:42 C8-189 systemd[1]: Started The nginx HTTP and reverse p>
[root@C8-189 ~]# cat /usr/lib/systemd/system/nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/apps/nginx/logs/nginx.pid
ExecStartPre=/bin/rm -f /apps/nginx/logs/nginx.pid
ExecStartPre=/apps/nginx/sbin/nginx -t
ExecStart=/apps/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[root@C8-189 ~]# ll /usr/local/bin/nginx
lrwxrwxrwx 1 root root 22 Jun 17 18:21 /usr/local/bin/nginx -> /apps/nginx/sbin/nginx
yum安装Nginx服务启动文件
[root@C8-194 ~]# systemctl enable --now nginx.service
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
[root@C8-194 ~]# systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vend>
Active: active (running) since Thu 2021-06-17 18:30:30 CST; 21s ago
Process: 3552 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCES>
Process: 3549 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/>
Process: 3547 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited>
Main PID: 3553 (nginx)
Tasks: 3 (limit: 11353)
Memory: 7.5M
CGroup: /system.slice/nginx.service
├─3553 nginx: master process /usr/sbin/nginx
├─3554 nginx: worker process
└─3555 nginx: worker process
Jun 17 18:30:30 C8-194 systemd[1]: Starting The nginx HTTP and reverse >
Jun 17 18:30:30 C8-194 nginx[3549]: nginx: the configuration file /etc/>
Jun 17 18:30:30 C8-194 nginx[3549]: nginx: configuration file /etc/ngin>
Jun 17 18:30:30 C8-194 systemd[1]: Started The nginx HTTP and reverse p>
[root@C8-194 ~]# cat /usr/lib/systemd/system/nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
# Nginx will fail to start if /run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=mixed
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[root@C8-194 ~]# which nginx
/usr/sbin/nginx
[root@C8-194 ~]# ll /usr/sbin/nginx
-rwxr-xr-x 1 root root 1264168 Oct 8 2019 /usr/sbin/nginx
``
以上是关于Linux编译和yum安装Nginx服务启动文件的主要内容,如果未能解决你的问题,请参考以下文章