Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am running Ubuntu Server 12.04 and prefer to compile PHP myself as opposed to installing it using apt-get. PHP is running as PHP-FPM.

When compiling extensions, I can set it to be compiled as a shared extension using something like --with-bcmath=shared and so on.

Are there any benefits to compiling the extensions as shared?

I also noticed that the extensions are compiled into a pretty convoluted folder. On my system (my php prefix is /usr/local/php-5.4.9) the extensions end up in /usr/local/php-5.4.9/lib/php/extensions/no-debug-non-zts-20100525.

Is there a global way to set a folder so that all shared extensions will be compiled in there? I understand that I can do something like --with-foobar=shared,/usr/local/foobar/ but having to set the extension folder for each shared extension is inefficient and error-prone.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Don't do that. Leave it as-is.

The "convoluted" directory structure nevertheless ensures that when you build future PHP extensions (that aren't shipped with PHP) that the build system can find your existing PHP installation and will put them in the right place so that your existing PHP installation can find them.

share|improve this answer
    
I have left the convoluted directory structure alone, because phpize and pecl automatically compiles extensions into the folder. Having said that, is there any benefit to compiling the extensions that come with PHP (things such as bcmath, calendar, etc) as shared extensions? –  F21 Dec 18 '12 at 5:39
    
Yes. By installing only the extensions your application actually uses, you can reduce PHP's RAM footprint, increasing the number of simultaneous requests you can handle with a given amount of RAM. In practice, this is a fairly minor gain, but it is still a gain, and is much more significant in resource-constrained VPS/cloud environments. –  Michael Hampton Dec 18 '12 at 5:44
    
Understood :) I am only installing extensions my application uses anyway. But when compiling, say bcmath, I have the option to do --enable-bcmath=shared or --enable-bcmath. The former will result in a bcmath.so file being generated and the latter a static library which is then linked to the php-fpm executable. Is there any benefit to having it as a shared library vs being statically linked? Are there any performance differences? –  F21 Dec 18 '12 at 5:49
    
Only at startup, which hopefully happens only once in a great while. :) –  Michael Hampton Dec 18 '12 at 5:50
    
Can you elaborate more? :) Personally, would you just leave them as statically linked or would you compile them as shared? :) –  F21 Dec 18 '12 at 5:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.