Jump to content

[RESOVLED - OR CLOSE ENOUGH]Recompile PHP


Recommended Posts

I am needing to recompile PHP on my webhost, which happens to be Server Powered.  They can do it for me, but I'd rather not have to always bother them to enable a new option when compiling the PHP binary.  I have root access to my account so I can do this myself; however I only know enough about the linux OS to be dangerous but not efficient.

After logging in, I change to dir / and issue the commands:
[code]
> find . -name "*php*.tar*"
./usr/local/cpanel/src/3rdparty/gpl/phpPgAdmin-4.0.1.tar.gz
./usr/local/cpanel/src/3rdparty/other/php-4.4.2.tar.gz
./usr/local/src/php-4.4.4.tar.gz

> cd /usr/local/src
> ls -l
total 5456
drwxr-xr-x   3 root root    4096 Nov 19 17:12 ./
drwxr-xr-x  22 root root    4096 Oct  8 09:47 ../
-rwxr-xr-x   1 root root     885 Nov 19 17:12 install_php.sh*
drwxr-xr-x  18 1000 1000    4096 Nov 19 17:17 php-4.4.4/
-rw-r--r--   1 root root 5555168 Aug 15 07:32 php-4.4.4.tar.gz

> more install_php.sh
cd php-4.4.4
./configure \
--with-apxs=/usr/local/apache/bin/apxs \
--prefix=/usr/local \
--with-xml \
--with-mm \
--enable-bcmath \
--enable-calendar \
--with-curl \
--with-dom \
--with-dom-xslt \
--with-dom-exslt \
--enable-exif \
--enable-ftp \
--with-gd \
--with-jpeg-dir=/usr/local \
--with-png-dir=/usr \
--with-xpm-dir=/usr/X11R6 \
--with-gettext \
--with-imap \
--with-imap-ssl \
--with-kerberos \
--enable-mbstring \
--enable-mbstr-enc-trans \
--enable-mbregex \
--with-mcrypt \
--with-mhash \
--enable-magic-quotes \
--with-mm \
--with-mysqli \
--with-mysql=/usr \
--with-openssl \
--enable-discard-path \
--with-pear \
--with-pspell \
--enable-xslt \
--with-xslt-sablot \
--enable-sockets \
--enable-track-vars \
--with-ttf \
--with-freetype-dir=/usr \
--enable-gd-native-ttf \
--enable-versioning \
--enable-wddx \
--with-xmlrpc \
--with-zip \
--with-zlib \
--enable-dbase
[/code]

From this I'm gathering that if I need to edit install_php.sh to enable or disable my PHP installation.  If i then run install_php.sh, I assume it changes me into the php-4.4.4 directory and runs the configure program.

From then, what do I need to do to compile and install PHP?  There already is apache (1.3 I believe) and PHP set up and running.  I'd like to just recompile PHP and stick it in the same place where it currently resides.  Can I keep my old php.ini or will a new one be created?  The webhost installed a PEAR module for me, will that still be available?

I have a pretty good sense of what I'm doing up until the actual point of compiling PHP, replacing the old one, and making sure I don't lose any of the old settings.

If it helps, inside my httpd.conf for the Apache server is the following:
[code]
LoadModule php4_module        libexec/libphp4.so
AddModule mod_php4.c
[/code]

Thanks for any help!
Link to comment
Share on other sites

I just did a search for libphp4.so and came up with:
[code]/usr/local/apache/libexec/libphp4.so
/usr/local/src/php-4.4.4/.libs/libphp4.so
/usr/local/src/php-4.4.4/libs/libphp4.so[/code]

Am I right to assume that when I do recompile PHP it will create a new libphp4.so in the /usr/local/src/php-4.4.4 area that I will need to copy over to /usr/local/apache/libexec ?
Link to comment
Share on other sites

Ok, so I'm able to compile and install a new libphp4.so.  For thoroughness and anyone else in this situation in the future, here's what I did.

From /usr/local/src:
[code]
> bash install_php.sh
> cd php-4.4.4
> make
> cp /usr/local/src/php-4.4.4/libs/libphp4.so /usr/local/apache/libexec/libphp4.so
> /usr/sbin/apachectl restart
[/code]

Now loading a phpinfo() page displays the new command line options I specified.  However, it doesn't solve the original problem I had set out to solve.

One of my scripts was using memory_get_usage() which is disabled if PHP is not built with the --enable-memory-limit option.  I suppose this particular installation doesn't allow that flag to be set, so I'll have to use a workaround function.

I'll probably just adapt this code, posted by [i]e dot a dot schultz at gmail dot com[/i] at http://php.net/memory_get_usage:
[code]
<?php
if( !function_exists('memory_get_usage') )
{
  function memory_get_usage()
  {
      //If its Windows
      //Tested on Win XP Pro SP2. Should work on Win 2003 Server too
      //Doesn't work for 2000
      //If you need it to work for 2000 look at http://us2.php.net/manual/en/function.memory-get-usage.php#54642
      if ( substr(PHP_OS,0,3) == 'WIN')
      {
              if ( substr( PHP_OS, 0, 3 ) == 'WIN' ):
              $output = array();
              exec( 'tasklist /FI "PID eq ' . getmypid() . '" /FO LIST', $output );
     
              return preg_replace( '/[\D]/', '', $output[5] ) * 1024;           
      }else
      {
          //We now assume the OS is UNIX
          //Tested on Mac OS X 10.4.6 and Linux Red Hat Enterprise 4
          //This should work on most UNIX systems
          $pid = getmypid();
          exec("ps -eo%mem,rss,pid | grep $pid", $output);
          $output = explode("  ", $output[0]);
          //rss is given in 1024 byte units
          return $output[1] * 1024;
      }
  }
}
?>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.