Linux离线安装Nginx
参考:https://blog.csdn.net/qq_33381971/article/details/123328191
https://www.cnblogs.com/rainbow-tan/p/16448004.html
1.环境部署
(1)网络环境:
(2)离线环境:
下载依赖包:
https://download.csdn.net/download/lqh_linux/87738988
把nginxpackage.tar.gz放在/home目录下
配置本地源:
[docker]
name=docker
baseurl=file:///home/nginxpackage/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
2.下载安装Nginx
官网直接下载.tar.gz安装包,地址:https://nginx.org/en/download.html
或者:https://nginx.org/download/nginx-1.24.0.tar.gz
把下载的nginx-1.24.0.tar.gz放在/home目录下
3.把Nginx添加到systemctl
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/home/nginx/logs/nginx.pid
ExecStartPre=/usr/bin/rm -f /home/nginx/logs/nginx.pid
ExecStartPre=/home/nginx/sbin/nginx -t
ExecStart=/home/nginx/sbin/nginx
ExecReload=/home/nginx/sbin/nginx -s reload
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[root@localhost sbin]
[root@localhost sbin]
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root@localhost sbin]
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since 五 2023-04-28 14:58:07 CST; 2min 36s ago
Main PID: 17884 (nginx)
CGroup: /system.slice/nginx.service
├─17884 nginx: master process /home/nginx/sbin/nginx
└─17885 nginx: worker process
4月 28 14:58:07 localhost.localdomain systemd[1]: Starting The nginx HTTP and reverse proxy server...
4月 28 14:58:07 localhost.localdomain nginx[17880]: nginx: the configuration file /home/nginx/conf/nginx.conf syntax is ok
4月 28 14:58:07 localhost.localdomain nginx[17880]: nginx: configuration file /home/nginx/conf/nginx.conf test is successful
4月 28 14:58:07 localhost.localdomain systemd[1]: Failed to parse PID from file /home/nginx/logs/nginx.pid: Invalid argument
4月 28 14:58:07 localhost.localdomain systemd[1]: Started The nginx HTTP and reverse proxy server.
验证:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)