Which is better: Static or dynamic extensions?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • George Adams

    Which is better: Static or dynamic extensions?

    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=small er core PHP and disadvantage=sl ower 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!


  • DrTebi

    #2
    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=small er core PHP and disadvantage=sl ower 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]

    Comment

    Working...