Recompiling PHP that was installed from RPM package?

Discussion in 'PHP' started by Kreshna, Nov 3, 2009.

  1. #1
    I need to recompile an existing PHP installation, but the PHP was installed from RPM package.

    Is it possible to recompile such RPM-installed PHP? And if that's the case, what things should I anticipate? What potential problems I'm going to face?

    I'm quite familiar in compiling from scratch, but I have never re-compiled anything before. I'm also unfamiliar with RPM. Should I use the usual ./make and /make install command, or should I use RPM instead? Can RPM recompile things?
     
    Kreshna, Nov 3, 2009 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    Yeah, it should be fine... When I do it, I leave the RPM installed version there and just put my compiled version in a different location. The default location for custom compiled versions is /usr/local/bin, so just make sure the RPM version isn't installed in there for some bizarre reason.
     
    digitalpoint, Nov 3, 2009 IP
  3. Kreshna

    Kreshna Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the reply. But instead of modifying the existing RPM-installed version, you just compile a new instance of PHP and put it in different location, don't you?

    How to tell Apache to use the new PHP instance?
     
    Kreshna, Nov 3, 2009 IP
  4. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #4
    Yep... that's correct. You will need to edit your Apache config files to tell it where the new module is located (when you compile, it will tell you where it installed it to).
     
    digitalpoint, Nov 3, 2009 IP
  5. Kreshna

    Kreshna Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks again, and glad to know I don't have to re-compile Apache. :)

    By the way, if the user already have existing Mambo/Joomla, this method won't distrupt the Mambo/Joomla, isn't it? Pardon the noob question but I'm unfamiliar with CMS.

    The reason I need to re-compile PHP is because I'm going to install MapServer PHPMapScript API on the production web server, but the server already has a running CMS-managed website.
     
    Kreshna, Nov 3, 2009 IP
  6. NatalicWolf

    NatalicWolf Peon

    Messages:
    262
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #6
    if you need help, pm me.
     
    NatalicWolf, Nov 3, 2009 IP
  7. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #7
    The Mambo/Joomla site will be upgraded to your custom compiled version of PHP... you can't run two different versions of PHP on the same web server (well not easily anyway).
     
    digitalpoint, Nov 3, 2009 IP
  8. Kreshna

    Kreshna Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thanks, digitalpoint, and you too, NatalicWolf.

    One last question though (I hope it will be the last):

    Intuitively (I said "intuitively" because I have never tried this before), I think compiling a "new instance" of PHP is much cleaner and safer than trying to overwrite your existing PHP installation. All you need to do is to change httpd.conf, restart Apache, and voila! Apache will use the newly installed PHP, and I will not break anything.

    And since this is production web server, I need to be very careful not to break anything.

    However, a friend of mine said that this method will likely overwrite a shared lib somewhere, that will break.

    Is that true? Considering the existing PHP doesn't even use MySQL, I guess nothing would break. What do you think?
     
    Kreshna, Nov 14, 2009 IP
  9. Kreshna

    Kreshna Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Well of course the site uses mySQL! Judging from its appearance, it appears to use mambo or other CMS products, which naturally uses MySQL.

    Furthermore, a further look on the phpinfo.php shows MySQL-related entries:
    and
    Questions:

    (1) How can the existing PHP connect to MySQL despite the ./ switch clearly says "--without-mysql"?

    (2) If I install a "new instance" of PHP, what should I do to keep the connection to the existing MySQL, thus avoid breaking the existing website?

    (3) If I overwrite the existing PHP by rebuilding the RPM, will the "newly upgraded" PHP retain its MySQL connection?

    (4) Besides MySQL, what other things should I worry about? What other components usually depends on a typical PHP installation? And do those components were also installed by defaults, whether I installed a new instance of PHP or rebuilding the RPM?

    Actually, what I need to do is nothing more than adding "--with-pgsql" switch on the existing PHP. I never thought it'll be that complicated. :(
     
    Kreshna, Nov 14, 2009 IP