Link to home
Start Free TrialLog in
Avatar of lunanat
lunanatFlag for Canada

asked on

Enable MSSQL.SO - Ubuntu 9.02 - apache2 - php5

So, I'm not a unix beginner, but I'm by no means a well versed user.

I'm trying to set up a LAMP server, minus the MySQL.  We have MS SQL servers, which I'd like the apache/php to work with.

To that effect, I've got a problem.  I can't seem to get php to load the mssql.so.  Using mssql_connect() generates an error saying that the function is undefined.

Phpinfo()  is in the code snippet.

My installation steps are as follows, from a clean install of ubuntu 9 (i386)
Prep:
      1) apt-get build-dep apache2
      2) apt-get build-dep php5
      3) apt-get build-dep freetds

A) apache2
      1) apt-get install apache2

B) freetds
      1) apt-get source freetds
      2) ./configure --prefix=/usr/local/freetds --wth-tdsver=8.0 --enable-msdblib --enable-dbmfix --with-gnu-ld
      3) make && make install
C) php5
      1) apt-get source php5
      2) ./configure --with-mssql=/usr/local/freetds
      3) make && make install
      4) apt-get install libapache2-mod-php5
      5) /etc/init.d/apache2 reset

D) mssql.so
      1) cd /ext/mssql
      2) phpize
      3) ./configure --with-mssql=/usr/local/freetds
      4) make && make install
      5) /etc/init.d/apache2 reset
E) php.ini
      1) nano /etc/php5/apache2/php.ini
            a) add extension=mssql.so to the extensions section
      2) /etc/init.d/apache2 reset

F) mssql.ini
      1) nano /etc/php5/conf.d/mssql.ini
            a) extension=mssql.so   <-- redundant to step E, but I figured it wouldn't hurt to try?
      2) /etc/init.d/apache2 reset

PHPInfo()  (there is no mssql section below the summary)
System  Linux lamp 2.6.31-14-generic-pae #48-Ubuntu SMP Fri Oct 16 15:22:42 UTC 2009 i686  
Build Date  Jan 6 2010 22:15:47  
Server API  Apache 2.0 Handler  
Virtual Directory Support  disabled  
Configuration File (php.ini) Path  /etc/php5/apache2  
Loaded Configuration File  /etc/php5/apache2/php.ini  
Scan this dir for additional .ini files  /etc/php5/apache2/conf.d  
additional .ini files parsed  /etc/php5/apache2/conf.d/mssql.ini, /etc/php5/apache2/conf.d/pdo.ini  
PHP API  20041225  
PHP Extension  20060613  
Zend Extension  220060519  
Debug Build  no  
Thread Safety  disabled  
Zend Memory Manager  enabled  
IPv6 Support  enabled  
Registered PHP Streams  https, ftps, compress.zlib, compress.bzip2, php, file, data, http, ftp, zip  
Registered Stream Socket Transports  tcp, udp, unix, udg, ssl, sslv3, sslv2, tls  
Registered Stream Filters  zlib.*, bzip2.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed

Open in new window

Avatar of Steve Bink
Steve Bink
Flag of United States of America image

Did you typo the path?  Your step (F) shows /etc/php5/conf.d/mssql.ini while your phpinfo() snippet shows /etc/php5/apache2/conf.d/mssql.ini.
Avatar of lunanat

ASKER

Hmm.. no I did not typo - doing a locate mssql.ini shows the file in /etc/php5/conf.d, however when I try to cp the file to /etc/php5/apache2/conf.d it says that the file is already present - and when I list that directory (and cat the file) things are indeed the way the phpinfo says it is.

Deleting the mssql.ini file out of apache2/conf.d also removed the file from php5/conf.d.  I recreated the file in apache2/conf.d (echo extension=mssql.so > mssql.ini), and restarted apache2.  No changes to the phpinfo, and no mssql support.
Restart your Apache service, then look in the main error log for any errors.  On my Ubuntu installation, the default log is /var/log/error.log.  I see this during the spin-up:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613/mssql.so' - /usr/lib/php5/20060613/mssql.so: cannot open shared object file: No such file or directory in Unknown on line 0

If you see a similar warning, try this command:

sudo find / -iname mssql.so
Avatar of lunanat

ASKER

Hmm.. I get a different error.  I'll start googling that error, but I'll post it here as well in case you have some ideas:

PHP Warning: PHP Startup: Invalid Library (maybe not a php library) 'mssql.so' in Unknown on line 0
Avatar of lunanat

ASKER

So, I think I'm running in the right direction now.. but wow did this just make a mess of things.

Since I'm running VMware, I'll just roll the snapshot back to a clean install and try everything again, but here's what I think the problem was (after some googling):

In PHP, I need to run the following configure:
./configure --with-mssql=/usr/local/freetds --with-apxs2=/usr/bin/apxs2

After doing this, it obliterated a lot of the phpinfo.. which is why I want to start fresh.. but after I've tried again, I'll let you know what happens.
Avatar of lunanat

ASKER

Dead end on the apxs2 configure option.. if it is a step in the right direction, it involves about 10 steps in the wrong direction first.

Using that config option kills about 85% of the pre-configured options... no php.ini file, for example.

I will keep googling other options, hope to hear from you soon.
ASKER CERTIFIED SOLUTION
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lunanat

ASKER

Thank you, after manually specifying all of the config settings (you weren't kidding when you said it'd be a long command), using the with-apxs2 command, everything works perfectly.

LAMP is now working with MSSQL.
That's not an answer!
What is the command you ended up using?  
That's the solution.