Something was wrong with the combination of PHP 5.3.5, php-mysql 5.3.5, and MySQL 5.5.8 on FreeBSD 8 earlier this month. Any attempt to run the command php -v resulted in PHP hanging after outputting the “Zend line”. Either kill(1) the process or type C-c to put it out of its misery, but neither action is any helpful.

In fact, this bug was only present when PHP was told through the contents of the file /usr/local/etc/php/extensions.ini to load the mysql.so module.

The users of rkhunter, PHP 5.3.5, and MySQL 5.5.8 would also experience this bug as rkhunter uses the command php -v to ascertain which version of PHP is installed on our systems.

My attempt at raising this issue only resulted in my bug report, PR ports/153790, being changed to fixed while the bug could still be clearly demonstrated in the hours that followed.

Or could the bug really be fixed, and what I’m doing, and how I do it, is plain wrong? If you have any comments regarding the following recipe, please speak up.

  1. First, boot off the FreeBSD/i386 8.1-RELEASE DVD1.
  2. Install a basic system, say only base, kernel (GENERIC), info, and man.
  3. Create the directory /usr/ports/packages using the command mkdir -p /usr/ports/packages.
  4. Download the ports hierarchy using the command csup and the file /usr/share/examples/cvsup/ports-supfile tailored to use your nearest CVSup mirror. The mirrors cvsup.no.FreeBSD.org and cvsup.fig.ol.no are two of my closest, and I opted for the latter.
  5. Compile and install the following ports in the following order. For each port listed below, I used the commands make config, make config-recursive (I ran this particular command twice or more in a row, just to catch setting options for any new dependencies), and finally make package.
    1. databases/mysql55-server. Accept the default port settings.
    2. lang/perl5.12. Enable the option for threaded Perl.
    3. www/apache22. Enable the option for MySQL support for apr-dbd (www/apache22) and the option for MySQL support in apr-util (devel/apr1). Did I just make the wrong turn, twice? Enable the use of libsigsegv (devel/m4). Enable all options but the use of GNU pth for threading/multiprocessing (lang/python26).
    4. databases/php5-mysql. Disable the option for the use of MySQL Native Driver (databases/php5-mysql). Is this where I should have done the opposite? Enable the option for building the Apache module (lang/php5).
  6. Ensure mysql.so really is listed in /usr/local/etc/php/extensions.ini. The command cat /usr/local/etc/php/extensions.ini should accomplish this task.
  7. Type the command /usr/local/bin/php -v and watch closely if the command ever exits on its own within a few milliseconds.
  8. Lo and behold, yes it does! Apparently mysql-server-5.5.8_3 and mysql-client-5.5.8_2 behaves differently than their previous port revisions, i.e. mysql-server-5.5.8 and mysql-client-5.5.8. None of the PHP ports has had any recent changes to their port revision numbers. Hopefully I will soon be up and running with rkhunter on my affected systems.

All of the above was carried out on between 2011-01-25T14:00 UTC and 2011-01-25T17:00 UTC.

For the sake of the scientific method, here are the contents of the files located in /var/db/ports.

/var/db/ports/apache22/options:

# This file is auto-generated by 'make config'.
# No user-servicable parts inside!
# Options for apache-2.2.17_1
_OPTIONS_READ=apache-2.2.17_1
WITHOUT_THREADS=true
WITH_MYSQL=true
WITHOUT_PGSQL=true
WITHOUT_SQLITE=true
WITH_IPV6=true
WITHOUT_BDB=true
WITH_AUTH_BASIC=true
WITH_AUTH_DIGEST=true
WITH_AUTHN_FILE=true
WITHOUT_AUTHN_DBD=true
WITH_AUTHN_DBM=true
WITH_AUTHN_ANON=true
WITH_AUTHN_DEFAULT=true
WITH_AUTHN_ALIAS=true
WITH_AUTHZ_HOST=true
WITH_AUTHZ_GROUPFILE=true
WITH_AUTHZ_USER=true
WITH_AUTHZ_DBM=true
WITH_AUTHZ_OWNER=true
WITH_AUTHZ_DEFAULT=true
WITH_CACHE=true
WITH_DISK_CACHE=true
WITH_FILE_CACHE=true
WITHOUT_MEM_CACHE=true
WITH_DAV=true
WITH_DAV_FS=true
WITHOUT_BUCKETEER=true
WITHOUT_CASE_FILTER=true
WITHOUT_CASE_FILTER_IN=true
WITHOUT_EXT_FILTER=true
WITHOUT_LOG_FORENSIC=true
WITHOUT_OPTIONAL_HOOK_EXPORT=true
WITHOUT_OPTIONAL_HOOK_IMPORT=true
WITHOUT_OPTIONAL_FN_IMPORT=true
WITHOUT_OPTIONAL_FN_EXPORT=true
WITHOUT_LDAP=true
WITHOUT_AUTHNZ_LDAP=true
WITH_ACTIONS=true
WITH_ALIAS=true
WITH_ASIS=true
WITH_AUTOINDEX=true
WITH_CERN_META=true
WITH_CGI=true
WITH_CHARSET_LITE=true
WITHOUT_DBD=true
WITH_DEFLATE=true
WITH_DIR=true
WITH_DUMPIO=true
WITH_ENV=true
WITH_EXPIRES=true
WITH_HEADERS=true
WITH_IMAGEMAP=true
WITH_INCLUDE=true
WITH_INFO=true
WITH_LOG_CONFIG=true
WITH_LOGIO=true
WITH_MIME=true
WITH_MIME_MAGIC=true
WITH_NEGOTIATION=true
WITH_REWRITE=true
WITH_SETENVIF=true
WITH_SPELING=true
WITH_STATUS=true
WITH_UNIQUE_ID=true
WITH_USERDIR=true
WITH_USERTRACK=true
WITH_VHOST_ALIAS=true
WITH_FILTER=true
WITH_VERSION=true
WITHOUT_PROXY=true
WITHOUT_PROXY_CONNECT=true
WITH_PATCH_PROXY_CONNECT=true
WITHOUT_PROXY_FTP=true
WITHOUT_PROXY_HTTP=true
WITHOUT_PROXY_AJP=true
WITHOUT_PROXY_BALANCER=true
WITHOUT_PROXY_SCGI=true
WITH_SSL=true
WITHOUT_SUEXEC=true
WITHOUT_SUEXEC_RSRCLIMIT=true
WITH_REQTIMEOUT=true
WITHOUT_CGID=true

/var/db/ports/apr/options:

# This file is auto-generated by 'make config'.
# No user-servicable parts inside!
# Options for apr-ipv6-devrandom-gdbm-db42-1.4.2.1.3.10
_OPTIONS_READ=apr-ipv6-devrandom-gdbm-db42-1.4.2.1.3.10
WITH_THREADS=true
WITH_IPV6=true
WITH_BDB=true
WITH_GDBM=true
WITHOUT_LDAP=true
WITH_MYSQL=true
WITHOUT_NDBM=true
WITHOUT_PGSQL=true
WITHOUT_SQLITE=true
WITH_DEVRANDOM=true

/var/db/ports/libiconv/options:

# This file is auto-generated by 'make config'.
# No user-servicable parts inside!
# Options for libiconv-1.13.1_1
_OPTIONS_READ=libiconv-1.13.1_1
WITH_EXTRA_ENCODINGS=true
WITHOUT_EXTRA_PATCHES=true

/var/db/ports/m4/options:

# This file is auto-generated by 'make config'.
# No user-servicable parts inside!
# Options for m4-1.4.15,1
_OPTIONS_READ=m4-1.4.15,1
WITH_LIBSIGSEGV=true

/var/db/ports/mysql/options:

# This file is auto-generated by 'make config'.
# No user-servicable parts inside!
# Options for mysql-server-5.5.8_3
_OPTIONS_READ=mysql-server-5.5.8_3
WITH_OPENSSL=true
WITHOUT_FASTMTX=true

/var/db/ports/mysql55-client/options:

# This file is auto-generated by 'make config'.
# No user-servicable parts inside!
# Options for mysql-client-5.5.8_2
_OPTIONS_READ=mysql-client-5.5.8_2
WITH_OPENSSL=true
WITHOUT_FASTMTX=true

/var/db/ports/perl/options:

# This file is auto-generated by 'make config'.
# No user-servicable parts inside!
# Options for perl-5.12.3
_OPTIONS_READ=perl-5.12.3
WITHOUT_DEBUGGING=true
WITHOUT_GDBM=true
WITHOUT_PERL_MALLOC=true
WITH_PERL_64BITINT=true
WITH_THREADS=true
WITHOUT_MULTIPLICITY=true
WITHOUT_SITECUSTOMIZE=true
WITH_USE_PERL=true

/var/db/ports/php5/options:

# This file is auto-generated by 'make config'.
# No user-servicable parts inside!
# Options for php5-5.3.5
_OPTIONS_READ=php5-5.3.5
WITH_CLI=true
WITH_CGI=true
WITHOUT_FPM=true
WITH_APACHE=true
WITHOUT_AP2FILTER=true
WITHOUT_DEBUG=true
WITH_SUHOSIN=true
WITHOUT_MULTIBYTE=true
WITH_IPV6=true
WITHOUT_MAILHEAD=true
WITHOUT_LINKTHR=true

/var/db/ports/php5-mysql/options:

# This file is auto-generated by 'make config'.
# No user-servicable parts inside!
# Options for php5-mysql-5.3.5
_OPTIONS_READ=php5-mysql-5.3.5
WITHOUT_MYSQLND=true

/var/db/ports/python26/options:

# This file is auto-generated by 'make config'.
# No user-servicable parts inside!
# Options for python26-2.6.6
_OPTIONS_READ=python26-2.6.6
WITH_THREADS=true
WITH_HUGE_STACK_SIZE=true
WITH_SEM=true
WITHOUT_PTH=true
WITH_UCS4=true
WITH_PYMALLOC=true
WITH_IPV6=true
WITH_FPECTL=true