Linux FPM 기반 RPM 패키지 만 들 기 (Nginx 의 경우)

5632 단어
1. Epel 구축  유미 원
 온라인 yum 소스 설치
[root@localhost ~]# rpm -ivh epel-release-latest-7.noarch.rpm      //     
[root@localhost yum.repos.d]# ls
a  epel-release-latest-7.noarch.rpm  epel-testing.repo  Centos-7.repo  epel.repo
 
  [root@localhost ~]# ls /etc/yum.repos.d/
  backup  CentOS-Base.repo  CentOS-Media.repo  epel.repo  epel-testing.repo
     epel.repo
  [root@Crushlinux yum.repos.d]# yum clean all && yum makecache  //     yum  

2. ruby 환경 과 gem 명령 설치 (gem 명령 은 ruby gem 창고 에서 소프트웨어 를 설치 하고 yum 창고 에서 소프트웨어 를 설치 하 는 것 과 유사 합 니 다)
     ,      3      
[root@localhost yum.repos.d]# yum -y install ruby rubygems ruby-devel

[root@localhost ~]# gem update --system      //  rubygems  
[root@localhost ~]# gem install rubygems-update -v 2.3.0    //     
[root@localhost ~]# gem update --system    //  

[root@localhost ~]# gem sources -a http://mirrors.aliyun.com/rubygems/  //     
[root@localhost ~]# gem sources --remove https://rubygems.org/        //     
[root@localhost ~]# gem sources -l     //     

[root@localhost ~]# gem install fpm     //  fpm  

3. nginx 를 컴 파일 하여 nginx 가 설치 되 었 음 을 보증 하 는 토대 에서 포장 하고 nginx 의 80 포트 를 봅 니 다.
[root@localhost ~]# netstat -anpt | grep :80    //  nginx   

4, 포장 nginx 패키지 생 성 rpm 패키지
  
[root@localhost ~]# vim nginx.sh
#!/bin/bash

useradd -M -s /sbin/nologin nginx        //    
ln -s /usr/local/nginx/sbin/nginx/ /sbin     //     
echo www.crushlinux.com > /usr/local/nginx/html/index.html   //            
/usr/local/nginx/sbin/nginx         //  nginx

포장
[root@localhost ~]# fpm -s dir -t rpm -n nginx -v 1.16.1 -d 'pcre-devel,zlib-devel' -f --post-install /root/nginx.sh /usr/local/nginx/
    
Need executable 'rpmbuild' to convert dir to rpm {:level=>:error}

  
[root@localhost ~]# yum list | grep build
[root@localhost ~]# yum -y install rpm-build
[root@localhost ~]# fpm -s dir -t rpm -n nginx -v 1.16.1 -d 'pcre-devel,zlib-devel' -f --post-install /root/nginx.sh /usr/local/nginx/
    ,          rpm 
Created package {:path=>"nginx-1.16.1-1.x86_64.rpm"}

5. 자신 이 만 든 패 키 지 를 설치 하고 포트 보기
설치 하기 전에 설치 한 nginx 를 마 운 트 해제 해 야 합 니 다.
rm -rf /usr/local/nginx
rm -rf /usr/src/nginx-1.16.1/
rm -rf /usr/local/nginx/sbin/nginx
userdel -r nginx
[root@localhost ~]# rpm -ivh nginx-1.16.1-1.x86_64.rpm    //        
[root@localhost ~]# netstat -anpt | grep 80     //    

 

좋은 웹페이지 즐겨찾기