I have successfully configured and compiled php on my dev server, and works great, but after talking to a sysadmin buddy, he informed that custom compiles of the latest builds are not recommended for production (or even development) systems. He noted a situation where they custom configured and compiled PHP 5.3.6, only to find that there was some issue with a low-level Postgres driver, so they had to revert back to 5.3.3.
So I am considering going back to yum to install PHP, however I have several custom configuration settings and was wondering if it's possible to pass or configure how PHP will be compiled through YUM?
My current configure line:
Configure Command => './configure' '--with-libdir=lib64' '--prefix=/usr/local/_custom/app/php' '--with-config-file-path=/usr/local/_custom/app/php/etc' '--with-config-file-scan-dir=/usr/local/_custom/app/php/etc/modules' '--disable-all' '--with-apxs2=/usr/sbin/apxs' '--with-curl=/usr/sbin/curl' '--with-gd' '--with-iconv' '--with-jpeg-dir=/usr/lib' '--with-mcrypt=/usr/bin' '--with-pcre-regex' '--with-pdo-mysql=mysqlnd' '--with-png-dir=/usr/lib' '--with-zlib' '--enable-ctype' '--enable-dom' '--enable-hash' '--enable-json' '--enable-libxml' '--enable-mbstring' '--enable-mbregex' '--enable-pdo' '--enable-session' '--enable-simplexml' '--enable-xml' '--enable-xmlreader' '--enable-xmlwriter'
Download src.rpm for the package, it contains ORIGINAL source code and all the files required for compiling custom rpm's:
To build rpm - you will need rpm-build package which contains rpmbuild program.
It also can be done with yumdownloader (from yum-utils package):
Install src.rpm:
cd to rpmbuild SPEC dir;
RHEL5, old Fedora
Suse:
RHEL6, newer Fedora:
php.spec file contains details about how package is built and which components will be included. It also contains data regarding dependencies and required packages to have in order to build new packages correctly. So, rpmbuild will remind you about any missing packages.
You will need to:
run rpmbuild:
rpmbuild --target x86_64 -ba php.spec
You can find built packages in ../RPM/ and ../SRPM/ directories.
This method ensures, that vendor patches are included, directory. file structure hierarchy is the same, component is compatible, dependencies are met and old version will be safely replaced. Also, you guarantee your future updates.
p.s. I disagree with "new version in production is bad" string. I am providing support services to dozen of companies, also have shared hosting and I always prefer to have fresh version. Only problem with php is moving from one subversion to another (like 5.1.x to 5.2.x, 5.2.x to 5.3.x) - there are some general changes and deprecated/removed functions. But newer is faster, secure and better maintained, followed.
p.s.s. I'll never compile anything manually and put files in /usr/local/ in my life, I've learned rpm as I needed it in few days, now everything is running smooth.
No, unfortunately you can't specify custom configure commands with yum. The software provided by yum and other similar package installers is pre-built per vendor specs.
I'd also recommend not going with the latest build of something just because its available, especially on production systems. I've encountered similar issues as your buddy where some strange bug reared its ugly head and I spent hours, days, weeks tracking it down...or just ended up reverting to the old build.
I would do a custom php build as you have done, which is what we do at my company. When a new stable version of php is out, we build it in /usr/local/php-x.x.x, test it, then update binary symlinks and shared libs in
/etc/ld.so.conf.d
and we're good. Developers always have requests for specific features, so its necessary for us to have the freedom and flexibility of a custom build. You could keep an eye on what version of php CentOS is recommending/distributing, and update at that time.Yum is not compiler
You can try to manually compile PHP:
like GioMac said and adding to it. The way to this is to take the source rpm of the version of php you have compiled from the yum repos and extract the src rpm and add your customization to it. Build the rpm and do a
Still that leaves the original concern of sys admin unanswered. Your customization to php may have a bug that didnt show up in your dev box. So one way to solve it would be to test it in a test environment and once satisfied push it to production.
yum is not a compiler. So installing through yum doesn't solve any problem that is present in the code. yum just make package dependencies solving easier. One benefit i see is that packages are to some extend tested before releasing it in stable branch of the repo. So if you want to compile it yourself then you loose the benefit of stable branch. if it is just configuration changes you would like to make then you can do that post installation also by editing the php.ini file.