Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A case study of customizing rpm package and Building yum Warehouse by Centos

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the Centos customized rpm package, the construction of yum warehouse case study, the article introduces in great detail, has a certain reference value, interested friends must read it!

1 keep the rpm package downloaded when yum installs the software

Just modify the yum configuration file. Downloaded rpm packages are automatically saved in the / var/cache/yum/ directory

[root@swag ~] # sed-I's keepcache0 keepcache1 etc/yum.conf [root@swag] # yum install sl- y [root@swag ~] # tree / var/cache/yum/x86_64/6/epel//var/cache/yum/x86_64/6/epel/ ├── 83f14a3d88054141092be5da12eb18cb1baabd7d52e1ae38bfc98d3d5005490c-primary.sqlite ├── cachecookie ├── packages │ sl-5.02-1.el6.x86_64.rpm └── repomd.xml1 directory, 4 files

2 compile and install Nginx

# Download tar.gz packagecd / home/oldboy/toolswget-Q http://nginx.org/download/nginx-1.6.3.tar.gz# Yum install Dependent packageyum install openssl openssl-devel-yyum install pcre pcre-devel-yrpm-qa pcre pcre-devel# Useradd wwwuseradd www-s / sbin/nologin-M# Compile and installtar-xf nginx-1.6.3.tar.gzcd nginx-1.6.3./configure-- user=www-- group=www-- with-http_ssl_module-- with-http_ Stub_status_module-- prefix=/application/nginx-1.6.3/make & & make install# Create a soft linkln-s / application/nginx-1.6.3/ / application/nginx# Start nginx/application/nginx/sbin/nginx# Check port 80lsof-I: 80

3 install the fpm tool

Install the dependency package first

Yum-y install zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel

The download ruby,fpm is written by ruby, so the system environment requires ruby. It is not recommended to install ruby in yum, there will be some problems during testing.

[root@swag tools] # wget https://ruby.taobao.org/mirrors/ruby/ruby-2.3.0.tar.gz[root@swag tools] # tar-xf ruby-2.3.0.tar.gz [root@swag tools] # cd ruby-2.3.0 [root@swag ruby-2.3.0] #. / configure [root@swag ruby-2.3.0] # make & & make install [root@swag ruby-2.3.0] # ruby- vruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux] [root@swag ~] # whereis gemgem: / usr/local/bin/gem [root@swag ~] # / usr/local/bin/gem install fpm [root@swag ~] # fpm-v1.9.adding Aliyun's Rubygems warehouse The default source is a foreign source, and the access and download speed is relatively slow. Before adding, remove the native Ruby repository [root@swag] # gem sources*** CURRENT SOURCES * * https://rubygems.org/ [root@swag ~] # gem sources-- remove https://rubygems.org/https://rubygems.org/ removed from sources# add Ali warehouse [root@swag] # gem sources-a http://mirrors.aliyun.com/rubygems/http://mirrors.aliyun.com/rubygems/ added to sources [root@ Swag ~] # gem sources*** CURRENT SOURCES * *

Http://mirrors.aliyun.com/rubygems/

Common parameters of fpm

-s: specify the source type

-t: specify the target type, that is, why you want to make the package

-n: specify the name of the package

-v: specify the version number of the package

-C: specify the relative path of packaging

-d: specify which packages to depend on

-f: if an installation package with the same name exists in the directory during the second package, overwrite it

-p: the directory of the output installation package. If you don't want to put it in the current directory, you need to specify it.

-- post-install: the script to be run after the package is installed; same as-- offer-install

-- pre-install: the script to be run before the package is installed; same as-- before-install

-- post-uninstall: the script to be run after the package has been uninstalled; same as-- offer-remove

-- pre-uninstall: the script to run before the package is uninstalled; same as-before-remove

Source type packages supported by fpm

Dir: packages the directory into the desired type, which can be used for source code compilation and installation software packages

Rpm: converting rpm

Gem: converting rubygem packages

Python: package the Python module into the appropriate type

Target type packages supported by fpm

Rpm: converting to rpm package

Deb: converting to deb package

Solaris: converting to solaris package

Puppet: converting to puppet package

4 package Nginx

[root@swag tools] # wget https://ruby.taobao.org/mirrors/ruby/ruby-2.3.0.tar.gz[root@swag tools] # tar-xf ruby-2.3.0.tar.gz [root@swag tools] # cd ruby-2.3.0 [root@swag ruby-2.3.0] #. / configure [root@swag ruby-2.3.0] # make & & make install [root@swag ruby-2.3.0] # ruby- vruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux] [root@swag ~] # whereis gemgem: / usr/local/bin/gem [root@swag ~] # / usr/local/bin/gem install fpm [root@swag ~] # fpm-v1.9.adding Aliyun's Rubygems warehouse The default source is a foreign source, and the access and download speed is relatively slow. Before adding, remove the native Ruby repository [root@swag] # gem sources*** CURRENT SOURCES * * https://rubygems.org/ [root@swag ~] # gem sources-- remove https://rubygems.org/https://rubygems.org/ removed from sources# add Ali warehouse [root@swag] # gem sources-a http://mirrors.aliyun.com/rubygems/http://mirrors.aliyun.com/rubygems/ added to sources [root@ Swag ~] # gem sources*** CURRENT SOURCES * * [root@swag tools] # wget https://ruby.taobao.org/mirrors/ruby/ruby-2.3.0.tar.gz[root@swag tools] # tar-xf ruby-2.3.0.tar.gz [root@swag tools] # cd ruby-2.3.0 [root@swag ruby-2.3.0] #. / configure [root@swag ruby-2.3.0] # make & & make install [root @ swag ruby-2.3.0] # ruby- vruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux] [root@swag ~] # whereis gemgem: / usr/local/bin/gem [root@swag ~] # / usr/local/bin/gem install fpm [root@swag ~] # fpm-v1.9.adding Aliyun's Rubygems warehouse The default source is a foreign source, and the access and download speed is relatively slow. Before adding, remove the native Ruby repository [root@swag] # gem sources*** CURRENT SOURCES * * https://rubygems.org/ [root@swag ~] # gem sources-- remove https://rubygems.org/https://rubygems.org/ removed from sources# add Ali warehouse [root@swag] # gem sources-a http://mirrors.aliyun.com/rubygems/http://mirrors.aliyun.com/rubygems/ added to sources [root@ Swag ~] # gem sources*** CURRENT SOURCES * *

5 other machine testing

# scp transfers the rpm packet to [root@swag] # scp nginx-1.6.3-1.x86_64.rpm root@10.0.0.5:/home/oldboy/tools# test [root@swag3 tools] # yum localinstall nginx-1.6.3-1.x86_64.rpm-y

6. Build yum warehouse

Install createrepo

[root@swag2 ~] # yum install createrepo-y

Create the yum warehouse directory and initialize the repodata index file

[root@swag2 ~] # mkdir-p / application/yum/centos6.9/x86_64/ [root @ swag2 ~] # cd / application/yum/centos6.9/x86_64/ # copy the customized rpm package to this directory [root@swag2 x86x64] # createrepo-pdo / application/yum/centos6.9/x86_64/ / application/yum/centos6.9/x86_64/

Provide yum services

# here python is used to provide web services, and apache or nginx can also be used to provide web services [root@swag2 x86 / 64] # python-m SimpleHTTPServer 80 & > / dev/null & # python's httpd module [root@swag2 x86 / 64] # lsof-I: 80COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEpython 24680 root 3u IPv4 32493 0t0 TCP *: http (LISTEN)

If a new rpm package is placed, it must be updated.

[root@swag2 x86: 64] # createrepo-- update / application/yum/centos6.9/x86_64/

Client modifies yum source

Cat > > / etc/yum.repo.d//etc/hosts# results show [root@swag5 data] # du-sh yum_data 21G yum_ data [root @ swag5 data] # tree-L 3 yum_data/yum_data/ ├── centos │ ├── 6 │ extras │ │ ├── os │ │ └── updates │ └── RPM-GPG-KEY-CentOS-6 ├── epel │ └── 6 │ └ ── x86x64 and above are Centos customized rpm packages, Case study of Building yum Warehouse "all the contents of this article Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report