Recompiling PHP on FC4 with Plesk 8.0.1

Original Post: August 27, 2006

I have to admit, this task is not for the faint of heart. This entry goes with my PHP Upload Progress Bar entry. I ported the entry from my old server, FC2 on Go Daddy’s Virtual Dedicated, to my new system, FC4 on Go Daddy’s Virtual Dedicated.

My goal is to recompile PHP with the PHP upload progress bar patch applied, while not breaking anything with Plesk!

All I am going to do is replace the “/etc/httpd/modules/libphp5.so” file on my system, and that’s it! Remember, I don’t want to break anything with my Plesk installation.

Ok, so first things first, backup the /etc/httpd/modules/libphp5.so file:

cp /etc/httpd/modules/libphp5.so /etc/httpd/modules/libphp5.so.orig

I started out by making a phpinfo.php page, so I could see my existing configure line. Turns out it looks like this:

‘./configure’ ‘–build=i386-redhat-linux’ ‘–host=i386-redhat-linux’ ‘–target=i386-redhat-linux-gnu’ ‘–program-prefix=’ ‘–prefix=/usr’ ‘–exec-prefix=/usr’ ‘–bindir=/usr/bin’ ‘–sbindir=/usr/sbin’ ‘–sysconfdir=/etc’ ‘–datadir=/usr/share’ ‘–includedir=/usr/include’ ‘–libdir=/usr/lib’ ‘–libexecdir=/usr/libexec’ ‘–localstatedir=/var’ ‘–sharedstatedir=/usr/com’ ‘–mandir=/usr/share/man’ ‘–infodir=/usr/share/info’ ‘–cache-file=../config.cache’ ‘–with-libdir=lib’ ‘–with-config-file-path=/etc’ ‘–with-config-file-scan-dir=/etc/php.d’ ‘–disable-debug’ ‘–with-pic’ ‘–disable-rpath’ ‘–with-bz2’ ‘–with-curl’ ‘–with-exec-dir=/usr/bin’ ‘–with-freetype-dir=/usr’ ‘–with-png-dir=/usr’ ‘–enable-gd-native-ttf’ ‘–without-gdbm’ ‘–with-gettext’ ‘–with-gmp’ ‘–with-iconv’ ‘–with-jpeg-dir=/usr’ ‘–with-openssl’ ‘–with-png’ ‘–with-pspell’ ‘–with-expat-dir=/usr’ ‘–with-pcre-regex=/usr’ ‘–with-zlib’ ‘–with-layout=GNU’ ‘–enable-exif’ ‘–enable-ftp’ ‘–enable-magic-quotes’ ‘–enable-sockets’ ‘–enable-sysvsem’ ‘–enable-sysvshm’ ‘–enable-sysvmsg’ ‘–enable-track-vars’ ‘–enable-trans-sid’ ‘–enable-yp’ ‘–enable-wddx’ ‘–with-pear=/usr/share/pear’ ‘–with-kerberos’ ‘–enable-ucd-snmp-hack’ ‘–with-unixODBC=shared,/usr’ ‘–enable-memory-limit’ ‘–enable-shmop’ ‘–enable-calendar’ ‘–enable-dbx’ ‘–enable-dio’ ‘–with-mime-magic=/etc/httpd/conf/magic’ ‘–without-sqlite’ ‘–with-libxml-dir=/usr’ ‘–with-xml’ ‘–with-apxs2=/usr/sbin/apxs’ ‘–without-mysql’ ‘–without-gd’ ‘–without-odbc’ ‘–disable-dom’ ‘–disable-dba’

Now, download the latest PHP tarball and patch tarball:

Untar PHP and the patch:

tar -xzvf php-5.1.6.tar.gz
tar -xzvf upload-progress-php-5.0.1-patch.tar.gz

Install patch, so I can patch the source:

yum install patch

Patch the PHP source:

cd php-5.1.6
patch -p1 < ../upload-progress-php-5.0.1-patch/upload-progress-php-5.0.1-patch

There was some fuzz, but the patch applied fine for me. Good, 5.0.1 patch still works on 5.1.6!

Then, I proceded with a series of “configure”, fix error, repeat procedure: pasting the configure line from above, receive error, resolve error, repeat. The packages I needed to install to get the configure command to complete without error are:

yum install bison
yum install flex
yum install libxml2-devel
yum install httpd-devel
yum install openssl-devel
yum install bzip2-devel
yum install bzip2-devel
yum install curl-devel
yum install gmp-devel
yum install unixODBC-devel
yum install pspell-devel

Next, run the make, but for me, the make failed:

/usr/local/src/php-5.1.6/main/rfc1867.c:35:19: error: mysql.h: No such file or directory
/usr/local/src/php-5.1.6/main/rfc1867.c: In function ‘update_progress_metter_file’:
/usr/local/src/php-5.1.6/main/rfc1867.c:792: error: ‘MYSQL’ undeclared (first use in this function)
/usr/local/src/php-5.1.6/main/rfc1867.c:792: error: (Each undeclared identifier is reported only once
/usr/local/src/php-5.1.6/main/rfc1867.c:792: error: for each function it appears in.)
/usr/local/src/php-5.1.6/main/rfc1867.c:792: error: syntax error before ‘mysql’
/usr/local/src/php-5.1.6/main/rfc1867.c:793: error: ‘MYSQL_RES’ undeclared (first use in this function)
/usr/local/src/php-5.1.6/main/rfc1867.c:793: error: ‘result’ undeclared (first use in this function)
/usr/local/src/php-5.1.6/main/rfc1867.c:794: error: ‘MYSQL_ROW’ undeclared (first use in this function)
/usr/local/src/php-5.1.6/main/rfc1867.c:794: error: syntax error before ‘row’
/usr/local/src/php-5.1.6/main/rfc1867.c:811: error: ‘mysql’ undeclared (first use in this function)
make: *** [main/rfc1867.lo] Error 1

This presented a challenge to me. There may be other ways around this, but what I did was download the MySQL 4.1 binary distribution from a mirror, then untar it, like this:

cd /usr/local/src
wget http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-standard-4.1.21-pc-linux-gnu-i686.tar.gz/from/http://mirrors.24-7-solutions.net/pub/mysql/
cd ..
tar -xzvf mysql-standard-4.1.21-pc-linux-gnu-i686.tar.gz
ln -s mysql-standard-4.1.21-pc-linux-gnu-i686 mysql

Then changed my configure line, getting rid of “‘–without-mysql'” and adding “‘–with-mysql=/usr/local/mysql/'”, did the configure again, then ran the make again, now it’s working! Not sure why the original configure line excluded mysql, I would think you’d want it compiled in, probably is extended later, but let’s just compile in now…

Wow, that was not for the faint of heart, but near the end of the process, I have a PHP upload bar enabled ./.libs/libphp5.so file ready. I’m excited.

Remember, I already backed up my existing /etc/httpd/modules/libphp5.so file, in case this doesn’t work. Also I AM NOT GOING TO RUN “make install” – I DO NOT WANT to replace my existing PHP installation, only the libphp5.so file!

Let’s drop it in place, and restart httpd:

cp .libs/libphp5.so /etc/httpd/modules/libphp5.so.withPHPupload
cp .libs/libphp5.so /etc/httpd/modules/libphp5.so
service httpd restart

Ug, my new libphp5.so module is looking for the mysql.sock file in the /tmp DIR. Oops, probably could have corrected that during the configure/compile stages, but it’s simple enough to just sym link it, works in a snap:

ln -s /var/lib/mysql/mysql.sock /tmp/

Now, I don’t touch the httpd.conf file, as suggested in the instructions. Instead, I drop a .htaccess file in the DIR I want to enabled the upload meter. I cd’d into my upload5 dir, created a .htaccess file and dropped this in:

php_value upload_metter 1
php_value upload_max_filesize 2097152
php_value upload_metter_mysql_host localhost
php_value upload_metter_mysql_user uploaduser
php_value upload_metter_mysql_pass xxxxxxxxxxxxxxxx
php_value upload_metter_mysql_db uploadbar

Dave.

Comments are closed.