安装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. Scratch 简单的小游戏 --- 碰碰球

    Scratch 简单的小游戏 --- 碰碰球 ================================ 积木脚本块的简要分类: 1. 角色 2. 背景 3. 角色和背景组成的场景 4. 挡板角 ...

  2. MT【299】对数型数列不等式

    已知数列$\{\dfrac{1}{n}\}$的前$n$项和为$S_n$,则下面选项正确的是(      )A.$S_{2018}-1>\ln 2018$B.$S_{2018}-1<\ln ...

  3. 洛谷AT2046 Namori(思维,基环树,树形DP)

    洛谷题目传送门 神仙思维题还是要写点东西才好. 树 每次操作把相邻且同色的点反色,直接这样思考会发现状态有很强的后效性,没办法考虑转移. 因为树是二分图,所以我们转化模型:在树的奇数层的所有点上都有一 ...

  4. 自学华为IoT物联网_10 IoT联接管理平台配置及开发实验1

    点击返回自学华为IoT物流网 自学华为IoT物联网_10 IoT联接管理平台配置及开发实验1 实验1:OceanConnect平台实验             通过基本的编程操作与配置,帮助读者熟悉O ...

  5. NOIP2013华容道(BFS+乱搞)

    n<=30 * m<=30 的地图上,0表示墙壁,1表示可以放箱子的空地.q<=500次询问,每次问:当空地上唯一没有放箱子的空格子在(ex,ey)时,把位于(sx,sy)的箱子移动 ...

  6. zabbix3.2监控mysql

    应用环境:ZABBIX一款强大的企业级可分布式的开源监控工具,从2.2版本开始支持MySQL监控(自带监控模板), 不过,默认添加MySQL模板后是无法使用的,这里小记一下部署监控MySQL的简单全过 ...

  7. hdu 3746 Cyclic Nacklace(kmp最小循环节)

    Problem Description CC always becomes very depressed at the end of this month, he has checked his cr ...

  8. JS监听滚动条进度

    HTML部分: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <s ...

  9. 以Attribute加上Header验证

    建立新FilterAttribute继承AuthorizationFilterAttribute,覆写OnAuthorization拦截传入的HttpActionContext内容判断是否有传入指定的 ...

  10. JAVA版本8u171与8u172的区别

    用了java 7好几年了,今天闲来无事,想升级到 java 8,到官网下载的时候发现JAVA放出了8u171与8u172两个版本. 什么情况? 百度一下找到答案:https://blog.csdn.n ...