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)
      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

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steve BinkCommented:
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.
lunanatAuthor Commented:
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.
Steve BinkCommented:
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
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

lunanatAuthor Commented:
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
lunanatAuthor Commented:
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.
lunanatAuthor Commented:
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.
Steve BinkCommented:
The configure command that you use needs to be complete.  For example, if you only put with-mssql and with-apxs2, you will *not* get tons of other options (such as mysql), hence your phpinfo report lacking what you expect to see.  A typical configure command is a looooong command.  See here for a partial list:


And try 'configure --help' with your particular version for a complete list of possibilities.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lunanatAuthor Commented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.