公司場景需求:離線伺服器上安裝一個nginx服務系統版本:CentOS 7.6
方法一:使用tar包,二進位制安裝 略
方法二:rpm方式安裝rpm包時,應該大家都遇到過缺少依賴包的問題,一個一個安裝依賴檔案,讓人頭疼。
這裡給大家介紹一種很方便的安裝方法使用yumdownloader命令離線安裝 nginx rpm服務包
1.首先找一個可以連線外網的伺服器
可以ping通百度域名,確定可以上外網[root@243-ceshi /]# ping www.baidu.comPING www.baidu.com icmp_seq=1 ttl=53 time=23.5 msicmp_seq=2 ttl=53 time=22.8 msicmp_seq=3 ttl=53 time=27.3 ms123456
2.安裝外掛
[root@localhost ~]# yum install yum-utils
3.建立一個存放rpm包的目錄
[root@localhost ~]# mkdir /rpm
4.下載nginx rpm相關檔案
[root@localhost rpm]# yumdownloader --resolve --destdir=/rpm nginx
5.檢視rpm目錄下的檔案
[root@243-ceshi rpm]# lscentos-indexhtml-7-9.el7.centos.noarch.rpm nginx-mod-http-image-filter-1.16.1-3.el7.x86_64.rpmgd-2.0.35-27.el7_9.x86_64.rpm nginx-mod-http-perl-1.16.1-3.el7.x86_64.rpmgperftools-libs-2.6.1-1.el7.x86_64.rpm nginx-mod-http-xslt-filter-1.16.1-3.el7.x86_64.rpmlibXpm-3.5.12-1.el7.x86_64.rpm nginx-mod-mail-1.16.1-3.el7.x86_64.rpmnginx-1.16.1-3.el7.x86_64.rpm nginx-mod-stream-1.16.1-3.el7.x86_64.rpmnginx-all-modules-1.16.1-3.el7.noarch.rpm openssl11-libs-1.1.1g-2.el7.x86_64.rpmnginx-filesystem-1.16.1-3.el7.noarch.rpm12345678
nginx最新版本的相關依賴檔案全在都rpm目錄下了
6.把rpm目錄下檔案移到內網伺服器的/rpm目錄下
[root@243-ceshi /]# scp -r /rpm [email protected]:/[email protected]'s password:centos-indexhtml-7-9.el7.centos.noarch.rpm 100% 92KB 19.7MB/s 00:00gd-2.0.35-27.el7_9.x86_64.rpm 100% 146KB 22.7MB/s 00:00gperftools-libs-2.6.1-1.el7.x86_64.rpm 100% 272KB 26.2MB/s 00:00libXpm-3.5.12-1.el7.x86_64.rpm 100% 55KB 17.6MB/s 00:00nginx-1.16.1-3.el7.x86_64.rpm 100% 563KB 31.4MB/s 00:00nginx-all-modules-1.16.1-3.el7.noarch.rpm 100% 20KB 8.2MB/s 00:00nginx-filesystem-1.16.1-3.el7.noarch.rpm 100% 21KB 9.0MB/s 00:00nginx-mod-http-image-filter-1.16.1-3.el7.x86_64.rpm 100% 30KB 12.0MB/s 00:00nginx-mod-http-perl-1.16.1-3.el7.x86_64.rpm 100% 39KB 14.3MB/s 00:00nginx-mod-http-xslt-filter-1.16.1-3.el7.x86_64.rpm 100% 29KB 11.9MB/s 00:00nginx-mod-mail-1.16.1-3.el7.x86_64.rpm 100% 57KB 16.6MB/s 00:00nginx-mod-stream-1.16.1-3.el7.x86_64.rpm 100% 85KB 18.1MB/s 00:00openssl11-libs-1.1.1g-2.el7.x86_64.rpm 100% 1485KB 40.6MB/s 00:00123456789101112131415
7.進入離線伺服器安裝
[root@localhost /]# cd /rpm[root@localhost rpm]# rpm -ivh * --nodeps --force警告:nginx-1.16.1-3.el7.x86_64.rpm: 頭V4 RSA/SHA256 Signature, 金鑰 ID 352c64e5: NOKEY準備中... ################################# [100%]正在升級/安裝... 1:openssl11-libs-1:1.1.1g-2.el7 ################################# [ 8%] 2:nginx-filesystem-1:1.16.1-3.el7 ################################# [ 15%] 3:libXpm-3.5.12-1.el7 ################################# [ 23%] 4:gd-2.0.35-27.el7_9 ################################# [ 31%] 5:gperftools-libs-2.6.1-1.el7 ################################# [ 38%] 6:centos-indexhtml-7-9.el7.centos ################################# [ 46%] 7:nginx-mod-http-image-filter-1:1.1################################# [ 54%] 8:nginx-mod-http-perl-1:1.16.1-3.el################################# [ 62%] 9:nginx-mod-http-xslt-filter-1:1.16################################# [ 69%] 10:nginx-mod-mail-1:1.16.1-3.el7 ################################# [ 77%] 11:nginx-all-modules-1:1.16.1-3.el7 ################################# [ 85%] 12:nginx-1:1.16.1-3.el7 ################################# [ 92%] 13:nginx-mod-stream-1:1.16.1-3.el7 ################################# [100%]12345678910111213141516171819
8.啟動nginx服務
[root@localhost rpm]# systemctl start nginx[root@localhost rpm]# systemctl status nginx● nginx.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled) Active: active (running) since 四 2021-01-21 15:24:46 CST; 5s ago Process: 127308 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS) Process: 127303 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS) Process: 127300 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS) Main PID: 127318 (nginx) Tasks: 7 Memory: 7.8M CGroup: /system.slice/nginx.service ├─127318 nginx: master process /usr/sbin/nginx ├─127319 nginx: worker process ├─127320 nginx: worker process ├─127322 nginx: worker process ├─127323 nginx: worker process ├─127324 nginx: worker process └─127325 nginx: worker process1月 21 15:24:46 vrgv systemd[1]: Starting The nginx HTTP and reverse proxy server...1月 21 15:24:46 vrgv nginx[127303]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok1月 21 15:24:46 vrgv nginx[127303]: nginx: configuration file /etc/nginx/nginx.conf test is successful1月 21 15:24:46 vrgv systemd[1]: Started The nginx HTTP and reverse proxy server.
完成
最新評論