WebFaction
Community site: login faq

Setup: Static/CGI/PHP-5.4

I'm building an application that has a connection to a MSSQL database - I'm setting up the connection with:

$dsn = 'dblib:dbname=DBNAME;host=DBHOST';
$conn = new PDO($dsn, MYUSER, MYPASSWORD);

"dblib" being the PDO driver. However, my current setup only has these drivers installed: mysql, pgsql, sqlite, sqlite2.

After looking online, I narrowed it down that I have to install the "PDO_DBLIB" Package (Found here: http://pecl.php.net/package/PDO_DBLIB). I began following these instructions on how to install: http://atutility.com/2007/09/14/install-pdo-pdo_sqlite-pdo_dblib-pdo_mysql. After the build command was entered, it printed this with an error at the last line:

$ pecl build
running: phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
building in /var/tmp/pear-build-username/PDO_DBLIB-1.0
running: /home/username/webapps/appname/PDO_DBLIB-1.0/configure
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ANSI C... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20060613
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for PDO_DBLIB support via FreeTDS... yes, shared
configure: error: Cannot find FreeTDS in known installation directories

So now my new task is getting FreeTDS installed. I got the .tgz file from its website, unpackaged it, put the folder on my server, cd'd to the folder and ran:

$  sh ./configure

This command fine. Based on the Installation instructions within the folder, the next step was to run "make". I entered this and it returned this error:

$ make
Making all in include
make[1]: Entering directory `/home/username/webapps/appname/freetds-0.91/include'
make  all-am
make[2]: Entering directory `/home/username/webapps/appname/freetds-0.91/include'
echo '#define FREETDS_SYSCONFDIR "/usr/local/etc"' >freetds_sysconfdir.h
make[2]: Leaving directory `/home/username/webapps/appname/freetds-0.91/include'
make[1]: Leaving directory `/home/username/webapps/appname/freetds-0.91/include'
Making all in src
make[1]: Entering directory `/home/username/webapps/appname/freetds-0.91/src'
Making all in replacements
make[2]: Entering directory `/home/username/webapps/appname/freetds-0.91/src/replacements'
/bin/sh ../../libtool --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../include  -I../../include -I../../src/replacements -D_FREETDS_LIBRARY_SOURCE -DUNIXODBC -DHAVE_UNISTD_H -DHAVE_PWD_H -DHAVE_SYS_TYPES_H -DHAVE_LONG_LONG -DSIZEOF_LONG=4  -D_REENTRANT -D_THREAD_SAFE -DDEBUG=1 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -pthread -g -O2 -Wdeclaration-after-statement -MT iconv.lo -MD -MP -MF .deps/iconv.Tpo -c -o iconv.lo iconv.c
: command not found 399: 
: command not found 402: 
: command not found 406: 
: command not found 427: 
: command not found 470: 
: command not found 476: 
../../libtool: line 486: syntax error near unexpected token `newline'
'./../libtool: line 486: `  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
make[2]: *** [iconv.lo] Error 2
make[2]: Leaving directory `/home/username/webapps/appname/freetds-0.91/src/replacements'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/username/webapps/appname/freetds-0.91/src'
make: *** [all-recursive] Error 1

and that's where I'm stuck. I've been looking everywhere on how to resolve this but haven't found anything helpful. So my questions are either: How can I fix this FreeTDS installation error? OR What's an alternative way I can get the dblib driver installed?

I would greatly appreciate any answers, guesses, tips, etc. Thanks much!

asked 28 Apr '12, 12:50

3vets
1111
accept rate: 0%


Hi,

FreeTDS is already installed on all our servers. Can you use the command:

rpm -qa|grep freetds

on your server?

Also, you have to use the commands:

phpize54
./configure --with-php-config=/usr/local/bin/php54-config
make
mkdir ~/php54-exts
cp modules/pdo_dblib.so ~/php54-exts/
# Customize the php.ini file of the desired web application, so that it loads the new extension
# MAKE SURE to replace 'htdocs' with the specific application you are enabling this for
echo "extension_dir = $HOME/php54-exts" >> ~/webapps/htdocs/php.ini
echo "extension = pdo_dblib.so" >> ~/webapps/htdocs/php.ini

instead of pecl build.

If PECL module still does not compile, you can install:

http://pkgs.org/centos-5-rhel-5/remi-testing-i386/php-mssql-5.4.1-1.el5.remi.i386.rpm.html

locally and use that.

mkdir ~/tmp
cd ~/tmp
wget http://rpms.famillecollet.com/enterprise/5/test/i386/php-mssql-5.4.1-1.el5.remi.i386.rpm
rpm2cpio php-mssql-5.4.1-1.el5.remi.i386.rpm | cpio -idmv --no-absolute-filenames
cd usr/lib/php/modules/
mkdir ~/php54_modules
cp pdo_dblib.so ~/php54_modules
ln -s /usr/local/lib/php54/extensions/no-debug-non-zts-20100525/* ~/php54_modules/
touch ~/webapps/<yourapp>/php.ini
echo "extension_dir = $HOME/php54_modules" >> ~/webapps/<yourapp>/php.ini
echo "extension = pdo_dblib.so" >> ~/webapps/<yourapp>/php.ini

The above RPM contains mssql.so too, so if you want to use that the process would be similar.

permanent link

answered 28 Apr '12, 22:03

neeravk
1.5k3412
accept rate: 41%

edited 22 Nov '13, 20:06

ryans ♦♦
5.0k93360

Thanks for your response! I ran:

$ rpm -qa|grep freetds

and it returned:

freetds-0.64-11.el5.centos

So I ran phpize54 and then entered:

$ ./configure --with-php-config=/usr/local/bin/php54-config

But it returned the same error as before:

configure: error: Cannot find FreeTDS in known installation directories

...confused, I guess its not recognizing where the FreeTDS is installed. Do you have any other suggestions on how this can be done?

Thanks for the info about hosting it locally but I'd rather get this configured on the server.

(29 Apr '12, 16:55) 3vets

You can build FreeTDS from source code, this is better since you will have the most recent version. The process is covered in a community post which covers a similar process for python. You can than typically find the way to specify the path for the library by running configure --help,

./configure --help

Someplace in the output the author should have placed a flag for specifying the FreeTLD path.

(29 Apr '12, 17:57) johns

Thanks for that link. I was able to follow the process and get FreeTDS installed.

But when I go back to install the PDO_DBLIB package, it still spits the same error:

configure: error: Cannot find FreeTDS in known installation directories

I looked in the Help options but wasn't sure which command should be used to specify the path. Any idea?

Thanks!

(04 May '12, 18:44) 3vets

Did you try installing using RPM as stated above yet? I just did one on test server locally and was able to get it working.

(04 May '12, 20:06) neeravk

Yeah, thanks for the tips above, I tried installing the RPM in your previous reply but it returned: "Couldn't resolve host 'php-mssql-5.4.1-1.el5.remi.i386.rpm'"

The tmp directory IS writable - I found that unwritable permissions may be an issue with that error. Thoughts?

(06 May '12, 22:26) 3vets

It is trying to use the rpm filename as a host which is odd.

Are you sure you used the command:

wget http://rpms.famillecollet.com/enterprise/5/test/i386/php-mssql-5.4.1-1.el5.remi.i386.rpm

worked properly?

(06 May '12, 22:30) neeravk
showing 5 of 6 show 1 more comments

I was able to resolve the issue by using the following commands:

mkdir ~/tmp ~/src
cd $HOME/src
wget http://rpms.famillecollet.com/enterprise/5/test/i386/php-mssql-5.4.3-1.el5.remi.i386.rpm
rpm2cpio php-mssql-5.4.3-1.el5.remi.i386.rpm | cpio -idmv --no-absolute-filenames
cd usr/lib/php/modules/
mkdir ~/php54_modules
cp pdo_dblib.so ~/php54_modules
ln -s /usr/local/lib/php54/extensions/no-debug-non-zts-20100525/* ~/php54_modules/

cd $HOME/src
wget http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz
tar -xzf freetds-stable.tgz
cd freetds-0.91
/configure --prefix=$HOME
make
make install
ln -s ~/lib/libtdsodbc.so ~/lib/libtds.so

echo "extension_dir = $HOME/php54_modules" >> ~/webapps/<my-app>/php.ini
echo "extension = pdo_dblib.so" >> ~/webapps/<my-app>/php.ini<your-app>

replacing <my-app> with the application name.

permanent link

answered 10 May '12, 12:55

3vets
1111
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×11
×3
×1
×1

question asked: 28 Apr '12, 12:50

question was seen: 19,796 times

last updated: 22 Nov '13, 20:06

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM