Linux uses Yum to install software locally

Source: Internet
Author: User
Tags gpg

Often encounter some Linux server for special reasons, can not connect the external network, but often need to install some software, especially when compiling some packages often due to not install some of the dependencies of the various errors reported, when you find the dependent RPM package to install, you are prompted to have other dependencies are not installed , very annoying. I remember when I first started playing Linux, I was so annoyed that I had to install a package for a whole morning, and the torture was almost a crash!

We know that Linux has a good tool, for our vast work on the Linux platform under the working class brought the gospel, that is the famous Yum software. It is very convenient when we can connect to the net, so how can we use Yum to install the software without the connection of the external network?

This article will give you a detailed description of how to use yum locally or on a local area network, for example CentOS, the case of this article was successfully deployed under centos5.5 64bit. There are two main ways to use Yum locally or on a local area network:

First, use the disc to mount directly to the local way

The advantage of this method is that it is fast and easy to operate. The disadvantage is that if you set up multiple servers, you need to mount them multiple times

First of all, let's look at how to mount the CD directly to the Local installation procedure as follows:

    1. Mount Disc to/mnt/cdrom/

mount/dev/cdrom/mnt/cdrom/

or mount the ISO file to this directory

Mount-o loop-t Iso9660/home/zhang/centos-5.5-x86_64-bin-dvd-1of2.iso/mnt/cdrom

    1. Edit the/etc/yum.repos.d/centos-media.repo file, clear the contents and enter the following information and save:

[C5-media]
name=centos-$releasever-media
baseurl=file:///mnt/cdrom/
Gpgcheck=1
Enabled=1
Gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-centos-5

    1. Remove the configuration file for the default network source (if any)

Mv/etc/yum.repos.d/centos-base.repo/etc/yum.repos.d/centos-base.repo.bak

    1. After doing this, you can test

Yum Clean all #清除缓存及旧的包
Yum install-y httpd #测试是否能安装软件

Simply 4 steps above, you can use your own source in the local, simple enough!

Second, Use Nginx or Apache wait Web Server to publish locally on the LAN Yum source of the way

The advantage of this approach is that it only needs to build a source, convenient, and faster than connecting to the outside network. The downside is that the operation is a bit more complicated than the first one, a little bit slower.

The installation steps are as follows:

1. Installing Nginx

U Install the Pcre library required for Nginx:

TARZXVF pcre-8.01.tar.gz

CD pcre-8.01/

./configure

make&& make Install

Cd.. /

U install Nginx

Tar zxvf nginx-0.8.34.tar.gz

CD nginx-0.8.34/

./configure--prefix=/usr/local/nginx--with-http_stub_status_module--with-http_ssl_module

Make && make install

2, all the RPM package is placed in a web directory nginx, and ensure that normal access, and configure

U mount disc to/mnt/cdrom/

mount/dev/cdrom/mnt/cdrom/

or mount the ISO file to this directory,

Mount-o loop-t Iso9660/home/zhang/centos-5.5-x86_64-bin-dvd-1of2.iso/mnt/cdrom

U Copy all rpm packages to/usr/local/nginx/html/centos directory

Cp-r/mnt/cdrom/centos//usr/local/nginx/html/

U configuration Nginx, so that the user can access all the RPM package, add the following content, IP attention to self-modification

Server

{

Listen 80;

server_name 192.168.3.201;

Index index.html index.htm;

root/usr/local/nginx/html/;

Access_log/usr/local/nginx/logs/centos_access.log access;

Location/{

AutoIndex on;

}

}

Verify that Http://192.168.3.201/CentOS see if you can access

3, put the certification files in a Web directory nginx, and ensure that normal access to

cp/mnt/cdrom/rpm-gpg-key-centos-5/usr/local/nginx/html/centos/

4. Create a yum repository with the Createrepo command and publish the Yum source

Before running this command, you need to install the createrepo-0.4.11-3.el5.noarch.rpm package,

rpm–ivh/mnt/cdrom/centos/createrepo-0.4.11-3.el5.noarch.rpm

Createrepo/usr/local/nginx/html/centos

5. Configure Yum Client

To edit a yum configuration file in a client

Vi/etc/yum.repos.d/centos-base.repo, after emptying the file, add the following:

[Base]

Name=centos 5.5 BIT

Baseurl=http://192.168.3.201/centos

Gpgcheck=1

Gpgkey=http://192.168.3.201/centos/rpm-gpg-key-centos-5

6. Testing

Yum–y Install httpd See if the software can be installed automatically

Summary: so far, how to set up the local Yum source is finished, you can pick a server in the local to recommend a local Yum source, later if a Linux machine yum need to install the software directly set local source can be, very convenient!

Linux installs the software locally using Yum (GO)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.