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
- 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)
- Install the rpms – libc-client and libc-client-devel rpms from Step 1
- Build the libc-client and libc-client-devel RPMs
- Install the above RPMs
IMPORTANT – Building the PHP RPM on RHEL 6.3 for php-5.4.6
As root,
- Create a folder in /usr/include – you can call it imap-keenable
- Create /usr/include/imap-keenable/include
- Create /usr/include/imap-keenable/lib
- 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
- copy *.c from $HOME/rpm/BUILD/imap-xxx/c-client to /usr/include/imap-keenable/lib
- copy c-client.a from $HOME/rpm/BUILD/imap-xxx/c-client to /usr/include/imap-keenable/lib
- rename /usr/include/imap-keenable/lib/c-client.a to /usr/include/imap-keenable/lib/libc-client.a
As a user,
- Make the required changes in makerpm script
- sh makerpm 5.4.6
- Source0: http://www.php.net/distributions/php-%{PACKAGE_VERSION}.tar.gz to Source0: http://www.php.net/distributions/php-%{version}.tar.gz
- Copyright: PHP License to License: PHP License
- ./buildconf to ./buildconf –force
- –without-pear \ to –with-pear \
- mv sapi/cgi/php php.keepme to mv sapi/cgi/php-cgi php-cgi.keepme
- –with-apxs=/usr/sbin/apxs \ to –with-apxs2=/usr/sbin/apxs \
- mv php.keepme sapi/cgi/php to mv php-cgi.keepme sapi/cgi/php-cgi
- 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
- RPMBASE=/usr/src/redhat to RPMBASE=${HOME}/rpm
- rpm -ba -v ${SPEC} to rpmbuild -ba -v ${SPEC}
- 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
- install -m 0755 modules/*.so $RPM_BUILD_ROOT%{_libdir}/php/extensions to install -m 0755 libs/*.so $RPM_BUILD_ROOT%{_libdir}/php/extensions
#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
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