php定制rpm包支持fpm---spec的书写

安装epel源

  1. yum install libmcrypt-devel mhash-devel mcrypt gettext glibc-common gd-devel \
  2. pcre-devel openldap-devel t1lib-devel icu libicu-devel libtidy-devel 
  1. Name:           php 
  2. Version:        5.3.21 
  3. Release:        1%{?dist} 
  4. Summary:        PHP is a widely-used general-purpose scripting  
  5. Vendor:         itnihao@qq.com 
  6. language. 
  7.  
  8. Group:          Development/Languages 
  9. License:        PHP License v3.01 
  10. URL:            http://www.php.net 
  11. Source0:        http://www.php.net/distributions/php-%{version}.tar.bz2 
  12. #Source1:        %{name}.conf 
  13. #Source2:        %{name}.ini 
  14. #Source3:        %{name}-fpm.conf 
  15. BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-buildroot 
  16.  
  17. Obsoletes:      php 
  18.  
  19. BuildRequires: make 
  20. BuildRequires: bzip2 >= 1.0.2-4 
  21. BuildRequires: curl-devel >= 7.19.7 
  22. BuildRequires: gd-devel >= 2.0.35 
  23. BuildRequires: libmcrypt-devel >= 2.5.8-2 
  24. BuildRequires: glibc-common >= 2.12 
  25. BuildRequires: mhash-devel >= 0.9 
  26. BuildRequires: mcrypt >= 2.6 
  27. BuildRequires: libtool-ltdl-devel >= 1.5.26-1 
  28. BuildRequires: libxml2-devel >= 2.6.32-2 
  29. BuildRequires: openldap-devel >= 2.4.23 
  30. BuildRequires: openssl-devel >= 0.9.8 
  31. BuildRequires: pcre-devel >= 7.8-2 
  32. BuildRequires: t1lib-devel >= 5.1.2-1 
  33. BuildRequires: zlib-devel >= 1.2.3-3 
  34.  
  35. %description 
  36. PHP is a widely-used general-purpose scripting language that is especially 
  37. suited for Web development and can be embedded into HTML. 
  38.  
  39. %prep 
  40. %setup -q -n %{name}-%{version} 
  41. %build 
  42. EXTENSION_DIR=%{_libdir}/php/modules; export EXTENSION_DIR 
  43. %configure  --with-layout=GNU --with-libdir=lib64 --enable-fpm --with-gd --enable-intl --enable-bcmath --enable-mbstring --enable-pcntl --enable-json --enable-soap  --enable-sockets --enable-sqlite-utf8 --enable-zip --with-zlib --with-bz2 --with-curl --with-jpeg-dir --with-freetype-dir --with-png-dir --with-iconv --with-xpm-dir --with-zlib-dir --with-gettext --with-pcre-regex --with-mcrypt --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --with-pdo-mysql=mysqlnd --with-pdo-sqlite --with-tidy=/usr --with-pear=%{_datadir}/php/pear --with-icu-dir=/usr --disable-debug 
  44.  
  45. make %{?_smp_mflags} 
  46.  
  47. %install 
  48. [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf %{buildroot} 
  49. mkdir -p %{buildroot}%{_initrddir} 
  50. install -Dp -m0755 sapi/fpm/init.d.php-fpm.in %{buildroot}%{_initrddir}/php-fpm 
  51. %{__make} install INSTALL_ROOT="%{buildroot}" 
  52.  
  53. %clean 
  54. [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf %{buildroot} 
  55.  
  56. %post 
  57. /sbin/chkconfig --add php-fpm 
  58. /sbin/chkconfig --level 2345 php-fpm on 
  59.  
  60. %preun 
  61. if [ "$1" = 0 ] ; then 
  62.     /sbin/service php-fpm stop > /dev/null 2>&1 
  63.     /sbin/chkconfig --del php-fpm 
  64. fi 
  65. exit 0 
  66.  
  67. %postun 
  68. if [ "$1" -ge 1 ]; then 
  69.     /sbin/service php-fpm condrestart > /dev/null 2>&1 
  70. fi 
  71. exit 0 
  72.  
  73. %files 
  74. %defattr(-,root,root,-) 
  75. %{_bindir}/* 
  76. %{_sbindir}/* 
  77. %{_includedir}/* 
  78. %{_libdir}/* 
  79. %{_mandir}/man1/php* 
  80. %{_sysconfdir}/* 
  81. %{_datadir}/* 
  82. %{_initrddir}/* 
  83. %exclude /.channels 
  84. %exclude /.depdb 
  85. %exclude /.depdblock 
  86. %exclude /.filemap 
  87. %exclude /.lock 
  88.  
  89.  
  90. %changelog 
  91. * Fri Jan 25 2013 Itnihao build   - 5.3.21-1 <itnihao@qq.com> 
  92.  
  93. * Wed Dec 21 2011 Mike Willbanks  - 5.3.8-1 
  94. - Updated to 5.3.8 
  95. * Tue Feb 23 2011 Mike Willbanks  - 5.3.5-1 
  96. - Initial Package 

本spec参考http://blog.digitalstruct.com/2011/12/21/rpm-packaging-building-and-deploying-your-own-php/而来

功能测试中,需继续完善,待续……