Skip to content

Instantly share code, notes, and snippets.

@crowjdh
Last active November 17, 2023 09:17
Show Gist options
  • Select an option

  • Save crowjdh/64dec7c33ce93d4ce7ca8aa9e4ff9b02 to your computer and use it in GitHub Desktop.

Select an option

Save crowjdh/64dec7c33ce93d4ce7ca8aa9e4ff9b02 to your computer and use it in GitHub Desktop.
Installing nginx for CentOS7 on the host that has no internet connection using yum

This process needs CentOS7 host that has internet connection for creating offline repo.

This particular example illustrates installing nginx specifically, but I think this should work for any other packages.

From CentOS with network connection

host-with-net:/# yum install yum-plugin-downloadonly yum-utils createrepo

host-with-net:/# mkdir -p /root/playground/nginx
host-with-net:/# mkdir -p /root/playground/nginx-installroot

host-with-net:/# vi /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
host-with-net:/# yum install --downloadonly --installroot=/root/playground/nginx-installroot --releasever=7 --downloaddir=/root/playground/nginx nginx

host-with-net:/# createrepo --database /root/playground/nginx
host-with-net:/# rm -rf /root/playground/nginx-installroot

host-with-net:/# vi /etc/yum.repos.d/offline-nginx.repo
[offline-nginx]
name=CentOS-$releasever - nginx
baseurl=file:///root/playground/nginx
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
host-with-net:/# repoclosure --repoid=offline-nginx

And then

Copy the offline repo that you just created(/root/playground/nginx) to the host that has no internet connection by any means(ex, docker cp, scp, via usb, ...).

From CentOS without network connection

host-without-net:/# vi /etc/yum.repos.d/offline-nginx.repo
[offline-nginx]
name=CentOS-$releasever - nginx
baseurl=file:///root/playground/nginx
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
host-without-net:/# yum --disablerepo=\* --enablerepo=offline-nginx install nginx --nogpgcheck

Reference: https://fabianlee.org/2016/10/02/node-js-packaging-modules-for-offline-deployment-using-npm-bundle/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment