1、搭建Epel Yum源
安装在线yum源
[[email protected] ~]# rpm -ivh epel-release-latest-7.noarch.rpm //安装扩展源 [[email protected] yum.repos.d]# ls a epel-release-latest-7.noarch.rpm epel-testing.repo Centos-7.repo epel.repo或
[[email protected] ~]# ls /etc/yum.repos.d/
backup CentOS-Base.repo CentOS-Media.repo epel.repo epel-testing.repo
[[email protected] yum.repos.d]# yum clean all && yum makecache //清除并新建yum缓存
2、安装ruby环境和gem命令(gem命令是从rubygem仓库安装软件,类似yum从yum仓库安装软件)
安装软件包,安装时要出现3个安装的软件 [[email protected] yum.repos.d]# yum -y install ruby rubygems ruby-devel [[email protected] ~]# gem update --system //升级rubygems版本 [[email protected] ~]# gem install rubygems-update -v 2.3.0 //安装新版本 [[email protected] ~]# gem update --system //升级 [[email protected] ~]# gem sources -a http://mirrors.aliyun.com/rubygems/ //添加国内源 [[email protected] ~]# gem sources --remove https://rubygems.org/ //移除国外源 [[email protected] ~]# gem sources -l //查看当前源 [[email protected] ~]# gem install fpm //安装fpm工具
3、编译nginx,在保证nginx安装完的基础上打包,查看nginx的80端口
[[email protected] ~]# netstat -anpt | grep :80 //查询nginx的接口
4、打包nginx包生成rpm包
脚本 [[email protected] ~]# 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
打包时报错,修改
[[email protected] ~]# 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} 修改 [[email protected] ~]# yum list | grep build [[email protected] ~]# yum -y install rpm-build [[email protected] ~]# 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、安装自己制作的软件包,并查看端口
[[email protected] ~]# rpm -ivh nginx-1.16.1-1.x86_64.rpm //安装自己制作的包 [[email protected] ~]# netstat -anpt | grep 80 //查看端口
原文地址:https://www.cnblogs.com/tanxiaojuncom/p/11525490.html
时间: 2024-10-19 14:53:39