Recompile PHP with iodbc

From OSF Wiki
Jump to: navigation, search

These steps are required to run OSF Web Service on x_64 bit Ubuntu (and probably most Linux distro's). There is an error in the unixodbc drivers that causes the load_ontologies.php step in the constructscs/structwsf installation procedure to fail with core dumps in Apache. The procedure below re-compiles and packages the current PHP5 release to work with iodbc, an alternative ODBC driver.

This bash script was used to build the PHP5 packages for the Ubuntu 14.04 LTS installation procedure. It was constructed from the PHP script for building PHP5 from source code. It was run in the following environment:

1. VMware Fusion virtual machine installed from a downloaded Ubuntu 14.04 x64 .iso file.

2. The following packages were added to the base install: Vim, Emacs, mailutils, Mutt, fetchmail.

3. Note1: this script was run on a VM that had *not* executed any of the OSF Install steps.

4. Note2: this script was run as root from a /tmp directory. sudo does not have enough permission to zero-out the file.

# build php5 from source w/ iodbc
# run as root, not sudo 
cd /tmp
# install latest updates
apt-get -y update
apt-get -y upgrade
mkdir -p /tmp/php5-install/update/build/
# install development scripts and tools
apt-get -y install devscripts
apt-get -y install debhelper
cd /tmp/php5-install/update/build/
# get php5 source code
apt-get -y source php5
cd php5-5.5.9+dfsg/debian
# change the dependencies from unixodbc to iodbc for the build process
sed -i '/unixodbc-dev,/d' /tmp/php5-install/update/build/php5-5.5.9+dfsg/debian/control
sed -i 's/unixODBC/iodbc/' /tmp/php5-install/update/build/php5-5.5.9+dfsg/debian/rules
# must be run as root; sudo does not have permission to zero out file
cat /dev/null > /tmp/php5-install/update/build/php5-5.5.9+dfsg/debian/
cd /tmp/php5-install/update/build/php5-5.5.9+dfsg/
# get php5 build dependencies
apt-get -y build-dep php5
# remove unixodbc dependencies
apt-get -y remove unixodbc-dev libodbc1 odbcinst odbcinst1debian2 unixodbc
# install iodbc and development dependencies
apt-get -y install iodbc libiodbc2-dev
# build can take hours depending on computing resources
debuild | tee /tmp/php5BuildOutput-$(date --iso-8601=seconds).log

Note - The build could take an hour or more to fully compile the PHP packages depending on your machine's specs. When completed, a set of new debian packages are built in the parent directory and are ready to be installed. This script creates a log file in /tmp/php5BuildOutput-$(date --iso-8601=seconds).log.

 ls ../*deb

Install package apache2-mpm-prefork.

 sudo apt-get install apache2-mpm-prefork

Install packages (replacing <version_no> with the version number you may have created in step 9):

 sudo dpkg -i php5-common_<version_no>_amd64.deb php5-cgi_<version_no>_amd64.deb php5-cli_<version_no>_amd64.deb php5-curl_<version_no>_amd64.deb libapache2-mod-php5_<version_no>_amd64.deb php5-mysql_<version_no>_amd64.deb php5-odbc_<version_no>_amd64.deb php5_<version_no>_all.deb