Create RHEL6 x86_64 rpms from PHP Source with IMAP support and mbstring

It has been quite frustrating to build php-imap and also add mbstring support to RHEL6 PHP RPM. I decided to build the RPMS from PHP Source and share it with all so that it spare someone the agony.. I am assuming rpmbuild and other utilities are installed to facilitate creation of RPMs

 

The tarball from the php download site contains a script called makerpm. This script creates and builds the rpm. Unfortunately, this script needs to be modified heavily

For IMAP

  1. The libc-client rpm needs to be installed. For this download the Source RPM from ftp.redhat.com and build rpms as a USER (NOT AS ROOT)
  2. Install the rpms – libc-client and libc-client-devel rpms from Step 1
  3. Build the libc-client and libc-client-devel RPMs
  4. Install the above RPMs

IMPORTANT – Building the PHP RPM on RHEL 6.3 for php-5.4.6

As root,

  1. Create a folder in /usr/include – you can call it imap-keenable
  2. Create /usr/include/imap-keenable/include
  3. Create /usr/include/imap-keenable/lib
  4. From the compiled folder, i.e. $HOME/rpm/BUILD/imap-xxx/c-client (depending on your version of imap downloaded from redhat site and assuming your top_dir in .rpmmacros is $HOME/rpm), copy *.h from $HOME/rpm/BUILD/imap-xxx/c-client to /usr/include/imap-keenable/include
  5. copy *.c from $HOME/rpm/BUILD/imap-xxx/c-client to /usr/include/imap-keenable/lib
  6. copy c-client.a from $HOME/rpm/BUILD/imap-xxx/c-client to /usr/include/imap-keenable/lib
  7. rename /usr/include/imap-keenable/lib/c-client.a to  /usr/include/imap-keenable/lib/libc-client.a

 

As a user,

  1. Make the required changes in makerpm script
  2. sh makerpm 5.4.6
Replacements in the makerpm script downloaded from the php site

  1. Source0: http://www.php.net/distributions/php-%{PACKAGE_VERSION}.tar.gz to Source0: http://www.php.net/distributions/php-%{version}.tar.gz
  2. Copyright: PHP License to  License: PHP License
  3. ./buildconf to ./buildconf –force
  4. –without-pear \ to –with-pear \
  5. mv sapi/cgi/php php.keepme to mv sapi/cgi/php-cgi php-cgi.keepme
  6. –with-apxs=/usr/sbin/apxs \ to  –with-apxs2=/usr/sbin/apxs \
  7. mv php.keepme sapi/cgi/php to mv php-cgi.keepme sapi/cgi/php-cgi
  8. install -m 0755 sapi/cgi/php $RPM_BUILD_ROOT%{_bindir}/php_cgi to install -m 0755 sapi/cgi/php-cgi $RPM_BUILD_ROOT%{_bindir}/php_cgi
  9. RPMBASE=/usr/src/redhat to RPMBASE=${HOME}/rpm
  10. rpm -ba -v ${SPEC} to rpmbuild -ba -v ${SPEC}
  11. install -m 0755 php.ini-recommended $RPM_BUILD_ROOT%{_sysconfdir}/php.ini to install -m 0755 php.ini-production $RPM_BUILD_ROOT%{_sysconfdir}/php.ini
  12. install -m 0755 modules/*.so $RPM_BUILD_ROOT%{_libdir}/php/extensions to install -m 0755 libs/*.so $RPM_BUILD_ROOT%{_libdir}/php/extensions
Lines to be Commented in the makerpm script downloaded from the php site

#for i in /usr/src/redhat /usr/src/packages /usr/src/RPM; do #if test -d $i; then #   RPMBASE=$i #  break #fi #done

AND

#%doc TODO CODING_STANDARDS CREDITS ChangeLog LICENSE NEWS

 

Lines to be Added in the makerpm script downloaded from the php site

In both the configure sections, add the following options –

–with-imap=/usr/include/imap-keenable \ –with-openssl \ –with-kerberos \ –enable-mbstring \

Finally, execute

$sh makerprm [PHP-Version]

 

You should have the RPMs built in your $HOME/rpm/RPMS/[Arch] folder

Leave a Reply

Your email address will not be published. Required fields are marked *