安装php依赖库

mkdir -pv ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

php有一个依赖库,在yum源于epel源中都没有需要自己打包libiconv

编写libiconv spec文件

%define __os_install_post %{nil}
%define debug_package %{nil}
Name: libiconv
Version: 1.15
Release: 1%{?dist}
Summary: liconv
Group: liconv
License: GPL
URL: http://www.test.net
Packager: test
Vendor: test
Source0: libiconv-1.15.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
%description
iconv %prep
%setup -q %build
./configure --prefix=/usr/share/libiconv-1.15 \ make %install
make install DESTDIR=%{buildroot} %files
%defattr(-,root,root,-)
%attr(0655,root,root) /usr/share/libiconv-1.15/*
%attr(0755,root,root) /usr/share/libiconv-1.15/bin/* %clean
rm -rf $RPM_BUILD_DIR/%{name}-%{version} %post
ln -sv /usr/share/libiconv-1.15/ /usr/share/libiconv %changelog
* Sun Aug 24 2018 LC 1.15-1
- package libiconv-1.15

编写php spec文件

Name: php
Version: 7.1.17
Release: 1%{?dist}
Summary: php
Group: php
License: GPL
URL: http://php.org
Packager: php
Vendor: php
Source0: php-7.1.17.tar.bz2
Source1: php.ini
BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot
Requires: libiconv,zlib-devel,libxml2-devel,libjpeg-devel,libjpeg-turbo-devel,freetype-devel,libpng-devel,gd-devel,curl-devel,libxslt-devel,bzip2-devel,gmp-devel,readline-devel,mcrypt,mhash,libmcrypt-devel
%description
php %prep
id nginx || useradd nginx -s /sbin/nologin -M
%setup -q %build
./configure \
--prefix=/usr/share/php-7.1.17 \
--with-config-file-path=/etc/php/ \
--exec-prefix=/usr \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--mandir=/usr/share/man \
--sysconfdir=/etc/php/ \
--with-mysqli=mysqlnd \
--with-iconv-dir=/usr/share/libiconv \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-libxml-dir \
--enable-xml \
--disable-rpath \
--enable-safe-mode \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--enable-short-tags \
--enable-zend-multibyte \
--enable-static \
--with-xsl \
--with-fpm-user=nginx \
--with-fpm-group=nginx make -j 4 %install
rm -rf %{buildroot}
make INSTALL_ROOT=%{buildroot} install
%{__install} -p -D %{SOURCE1} %{buildroot}/etc/php/php.ini %files
%defattr(-,root,root,-)
/usr/share/php-7.1.17/*
%attr(0744,root,root) /usr/bin/*
%attr(0744,root,root) /usr/sbin/*
/usr/share/man/*
/etc/php/* %pre
id nginx || useradd nginx -s /sbin/nologin -M %post
cp /etc/php/php-fpm.conf.default /etc/php/php-fpm.conf
cp /etc/php/php-fpm.d/www.conf.default /etc/php/php-fpm.d/www.conf %postun
userdel nginx %changelog
* Sun Aug 10 2018 lc lc
- package php-7.1.71

构建PHP RPM包遇到的问题

RPM build errors:
bogus date in %changelog: Sun Aug 10 2018 lc zhoushilong
Explicit %attr() mode not applicaple to symlink: /root/rpmbuild/BUILDROOT/php-7.1.17-1.el7.centos.x86_64/usr/bin/phar
Installed (but unpackaged) file(s) found:
/.channels/.alias/pear.txt
/.channels/.alias/pecl.txt
/.channels/.alias/phpdocs.txt
/.channels/__uri.reg
/.channels/doc.php.net.reg
/.channels/pear.php.net.reg
/.channels/pecl.php.net.reg
/.depdb
/.depdblock
/.filemap
/.lock

解决方法如下:

方法1
生成的rpm包里有前面在%files里添加的这个文件,如下:

/usr/local/php/.channels

方法二,下面是直接删除的解决办法,实践OK(视具体情况是删除还是添加选一个即可):

rm -rf %{buildroot}/{.channels,.depdb,.depdblock,.filemap,.lock}

方法三,/usr/lib/rpm/macros修改宏

# 构建根目录中的未打包文件是否应终止构建?
%_unpackaged_files_terminate_build 1 # 把1改为0只警告 %__check_files %{_rpmconfigdir}/check-files %{buildroot} # 这一行,把这一行注释掉,然后重新编译

rpmbuild打包php的更多相关文章

  1. 使用rpmbuild打包时不对文件进行strip操作

    使用rpmbuild打包时不对文件进行strip操作 摘自: https://www.ichenfu.com/2017/11/20/rpmbuild-not-strip/ By Chen Fu 发表于 ...

  2. rpmbuild打包

    安装: yum  install -y rpm-build 目录介绍: 默认目录在  /root/rpmbuild BUILD :你要打包的文件将会在这里编译(编译rpm包的临时目录) BUILDRO ...

  3. 利用rpmbuild 打包可执行文件和链接库生成rpm 包

    Background: Background: 遇到一个打包可执行程序和链接库生成rpm 包的需求,查遍了很多网站的资料,现在整理下解决方案. 前期参考的是这篇帖子: https://codeante ...

  4. RPM打包原理、示例、详解及备查

    原文地址:https://blog.csdn.net/qq_16542775/article/details/80961213 RPM(Redhat Package Manager)是用于Redhat ...

  5. RPM打包原理、示例、详解及备查( 转)

    RPM(Redhat Package Manager)是用于Redhat.CentOS.Fedora等Linux 分发版(distribution)的常见的软件包管理器.因为它允许分发已编译的软件,所 ...

  6. linux之使用rpmbuild打rpm包

    linux之使用rpmbuild打rpm包 前言: 已从事linux运维工作数年,感觉自己还是个小菜鸟,没有大神那么的钻研的精神.只是单纯热爱,喜欢对着黑色的屏幕敲击命令,喜欢这种感觉.为什么要做RP ...

  7. [实践] ubuntu下编译安装ambari

    ambari是一个Hadoop套件的管理工具,可以方便部署.管理及监控.最初开发时使用的就是RH系的Linux,只支持RHEL.CentOS5/6.OEL.SLES,暂不支持Ubuntu:可我的需求就 ...

  8. 在Linux CentOS 6.5 (Final)上安装git-1.9.0

    CentOS 6.5 (Final)默认安装的git版本为1.7.1.3,而我们希望安装1.9.0版本.由于rpm安装库里没有1.9.0版本,因此我们需要找其它方法来安装. 网上有很多文章介绍了如何从 ...

  9. 编译wiredtiger rpm包

    1.安装rpm-build 使用rpmbuild打包rpm包前,首先安装rpmbuild: yum install rpm-build -y 2.创建打包文件目录 mkdir  -p  /root/r ...

随机推荐

  1. 「NOI2003」逃学的小孩

    传送门:>HERE< 题意:给出一棵树(带权),要从一个节点C先走到距离它近的一个节点B,再走到A,要求最坏情况下的总路程(即最长). 解题思路: 乍一看,A,B,C都没给出,这怎么求? ...

  2. Linux iptables设置

    先举例子说明,若服务器网卡: eth0 10.10.0.100 eth0:0 10.10.0.200 eth0:1 10.10.0.201 eth0:2 10.10.0.202 只允许10.10.0. ...

  3. Android 获取SD路径,存储空间大小的方法

    Android用 Environment.getExternalStorageDirectory() 方法获取 SD 卡的路径 , 卡存储空间大小及已占用空间获取方法 : /* 获取存储卡路径 */ ...

  4. linux rpm安装 failed depenencie(失败的依赖关系)错误原因

    rpm安装nfs 出现failed depenencie 经查资料得知命令后加上--nodeps --force,就可以了 加上那两个参数的意义就在于,安装时不再分析包之间的依赖关系而直接安装,也就不 ...

  5. CAN协议,系统结构和帧结构

    CAN:Controller Area Network,控制器局域网 是一种能有效支持分布式控制和实时控制的串行通讯网络. CAN-bus: Controller Area Network-bus,控 ...

  6. Spring Data JPA Batch Insertion

    转自:https://www.jeejava.com/spring-data-jpa-batch-insertion/ Spring Data JPA Batch Insertion will sho ...

  7. 利用nginx进行集群部署

    现在一般的服务器都是集群的情况了,所以准备搞集群部署下. nginx用的是第三方的openrestynginx.首先安装nginx,我的系统是UBuntu,安装方法也很简单,见官网. 自己采用了默认安 ...

  8. Mysql DML DCL DDL

    在介绍这些SQL语言之前,先罗列一下mysql的常用数据类型和数据类型修饰,供查询参考 后面的带数字表示此类型的字段长度 数值型: TINYINT 1 ,SMALLINT 2,MEDIUMINT 3 ...

  9. Python之迭代器,生成器

    迭代器 1.什么是可迭代对象 字符串.列表.元组.字典.集合都可以被for循环,说明他们都是可迭代的. from collections import Iterable l = [1,2,3,4] t ...

  10. qrcode.js 动态生成二维码

    用qrcode.js动态生成二维码图片非常简单,只需要引入qrcode.js即可使用,而且可以自定义图片大小.背景色等信息. 1.jsp代码---页面头部引入qrcode.js,jquery文件可选 ...