Connecting Tech Pros Worldwide Help | Site Map

Which is better: Static or dynamic extensions?

  #1  
Old July 17th, 2005, 02:36 AM
George Adams
Guest
 
Posts: n/a
I like the idea of compiling DSO modules for Apache. It allows me to turn
on or off things we may or may not need at a given time (like mod_ssl,
mod_auth_mysql, mod_auth_ldap, etc.) and also allows me to compile in new
versions of modules without having to rebuild Apache from scratch.

Now, when I build PHP, I tend to put in a lot of things. Like:





../configure --with-mysql=/usr --with-openssl --with-pdflib=/usr/local --with
-bz2 --with-mhash --with-mcrypt ...

etc. etc. All of these modules are things that we use, but some of them not
very frequently.

So I'm trying to learn more about PHP's dynamic extensions. I didn't even
know that they existed, until I looked at the php.ini and phpinfo() output
of the PHP version that comes with RedHat 9.0. I see that instead of doing
things like:

./configure --with-mysql=/usr

they do

./configure --with-mysql=shared,/usr

So I guess my questions are:

1) Where can I learn more about PHP dynamic extensions? Maybe I'm looking
in the wrong places, but the documentation on them seems to be quite light.

2) Can *any* module be compiled as a dynamic extension, just by putting
"shared" in the appropriate place in the ./configure command? Or just a
few? How can you figure out which ones can, and which ones can't?

3) What are the advantages and disadvantages to making dynamic extensions?
I'm guessing that advantage=smaller core PHP and disadvantage=slower initial
load time. Is that right? Anything else?

4) Similar to #3, is building dynamic extensions whenever possible
considered a Good Thing? Or are most people just still building everything
into a single monolithic libphp4.so ?

Thanks!


  #2  
Old July 17th, 2005, 02:36 AM
DrTebi
Guest
 
Posts: n/a

re: Which is better: Static or dynamic extensions?


That is quite interesting. I did not know that not only apache, but also
PHP allows you to use shared libraries.

I have heard many times that PHP is faster when it is compiled statically
into the httpd.
I have always done it that way, I actually always compiled _all_ apache
modules statically (maybe I am a speed freak?). However, it has a big
disadvantage: If you want to upgrade PHP, you have to recompile PHP and
apache with all modules again. That can be a bit tedious at times.
With my next server I will rather build PHP and others as a shared
modules, it leaves more flexibility when wanting to change things later.

As for shared PHP modules, I suggest you do this in your PHP source
directory:
../configure --help > configure-help
Then open the configure-help file and read through it. It specifically
states there:
NOTE: Not all extensions can be build as 'shared'.
Unfortunately it does not tell you much more, there are a couple comments
in the config help though that tell you something like "this can be a
shared module" etc. I suppose those are the only ones you can build as
shared modules, but I am not sure.

But then again, I think PHP is really very fast already, so do you really
need to have shared modules for PHP as well? I don't know. I have read a
few threads that were comparing PHP to other scripting languages, stating
that PHP comes with too many functions. That's very wrong though. You may
find over 2000 functions in the manual, but most people will never build
PHP with support for all those functions. My typical installation includes
only a bit more than 700 functions, and I have never found PHP to be too
slow.

DrTebi


On Thu, 11 Dec 2003 11:31:58 -0500, George Adams wrote:
[color=blue]
> I like the idea of compiling DSO modules for Apache. It allows me to turn
> on or off things we may or may not need at a given time (like mod_ssl,
> mod_auth_mysql, mod_auth_ldap, etc.) and also allows me to compile in new
> versions of modules without having to rebuild Apache from scratch.
>
> Now, when I build PHP, I tend to put in a lot of things. Like:
>
>
>
>
>
> ./configure --with-mysql=/usr --with-openssl --with-pdflib=/usr/local --with
> -bz2 --with-mhash --with-mcrypt ...
>
> etc. etc. All of these modules are things that we use, but some of them not
> very frequently.
>
> So I'm trying to learn more about PHP's dynamic extensions. I didn't even
> know that they existed, until I looked at the php.ini and phpinfo() output
> of the PHP version that comes with RedHat 9.0. I see that instead of doing
> things like:
>
> ./configure --with-mysql=/usr
>
> they do
>
> ./configure --with-mysql=shared,/usr
>
> So I guess my questions are:
>
> 1) Where can I learn more about PHP dynamic extensions? Maybe I'm looking
> in the wrong places, but the documentation on them seems to be quite light.
>
> 2) Can *any* module be compiled as a dynamic extension, just by putting
> "shared" in the appropriate place in the ./configure command? Or just a
> few? How can you figure out which ones can, and which ones can't?
>
> 3) What are the advantages and disadvantages to making dynamic extensions?
> I'm guessing that advantage=smaller core PHP and disadvantage=slower initial
> load time. Is that right? Anything else?
>
> 4) Similar to #3, is building dynamic extensions whenever possible
> considered a Good Thing? Or are most people just still building everything
> into a single monolithic libphp4.so ?
>
> Thanks![/color]

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Content in High-Traffic Sites pbd22 answers 9 June 25th, 2007 01:35 PM
Is python for me? lennart answers 22 November 22nd, 2006 07:45 AM
Is C99 the final C? Michael B. answers 193 November 14th, 2005 04:46 PM
Is Python your only programming language? Joe Cheng answers 33 July 18th, 2005 02:38 AM