For the past few years, I’ve always ran Apache, PHP and MySQL under Windows, only ever using Linux for my production environment (which I rarely had to touch). I’m not making the jump to a Ubuntu virtual machine to host my LAMP development environment. The biggest difference I’ve noticed between PHP on Windows and PHP on Linux is how they handle extensions. On Windows, when you install PHP, you get a whole load of extensions under the “ext” directory which you can enable or disable at leisure. With PHP on Linux though, you don’t get this, instead you need to compile PHP with all the extensions you wish to use, or think you may use in the future. If you ever change you’re mind you have to re-configure, re-make and re-install PHP.
I was wondering if there was a more Windows approach to extensions on Linux, or if I’m start with re-building PHP every time I want to add or remove an extension. I guess the same question is, is there anywhere on the internetz that offers a repository of pre-compiled “.so” php modules which would be compatible with Ubuntu 9.10?
Note, this isn’t even mentioning the hassle of finding all the dependencies required to build extensions with PHP. It took me almost an hour just to add a couple of common extensions to my PHP build.
Dynamic libraries work the same in Linux as they do for you in Windows. The only difference is the file extension – .so vs .dll. You don’t have to recompile PHP to enable or disable them, you just add them to your php.ini, the same as you did in Windows.
I’m sure most non-standard extensions you would want to add are available through apt-get or whatever Ubuntu’s package manager is. I run RedHat/CentOS on all my servers, and installing a PHP extension is just one command, which doesn’t involve compiling PHP.
All the standard ones are already be installed, and you’ll find their configurations in the php.d directory. I’m not sure where Ubuntu puts the extensions themselves… probably /usr/lib/php/modules?
Thanks for the reply Dan. Just to clarifying, I’m building PHP from source, and so need to explicitly tell the configure script which PHP options and extensions I’d like. This does not generate “.so” php extensions, but instead seems to compile these extensions into PHP. There is a “ext” folder in the PHP source directory which has all the extensions you’d expect, but in there uncompiled form. I guess I could always compile the individual extensions as php modules, but is there not a pre-compiled php extension repository out there somewhere?
A few of the extensions relied on 3rd party libraries, plus there were a few other little hiccups, but nothing Google couldn’t solve. For anyone else planning on doing this, one thing I can tell you is that you need to install “autoconf” before you’ll be able to compile php extensions using the steps in the above link.
I just don’t want to be dependant on the package manager, plus it seems only a sub-set of extensions is available via the package manager. Compiling extensions myself takes a little longer, and you do get problems with some of the extensions (missing dependencies) but otherwise, it seems like the most flexible and modular solution, which is what attracts me to it. Thanks for all your input though.
Stormrider, I’m not quite sure what you’re talking about. What does “–with-config-file-path” achieve exactly? I compiled PHP with the intention of adding/creating a php.ini file afterwards. What’s the disadvantage of this compared to what you’re referring to?