Monday, May 9, 2011

Caught in the Details

Last week I had time to do what I had meant to do the week before, set up a Linux server for another group at work. The requirements were simple: Apache + PHP, using a SQL Server database on one of our Windows servers. This proved to be a little more complicated than I thought:
  • FreeTDS (for the database layer) went in without problems, so that was easy enough. Configuring obbcinst.ini and odbc.ini was easy.
  • My own preference with PHP is to use PDO for database work. But libc6 decided that PDO was taking indecent liberties with the stack. So, no PDO.
  • ODBC? Well, I've never used it under Linux, certainly never with PHP.Something I Googled spoke of it faking the binding of variables on SQL Server. So, not ODBC.
  • The mssql_connnect was fine.
  • Then I discovered why PHP's odbc procedures fake  binding against SQL Server; SQL Server doesn't want to bind variables against anything but a stored procedure. Who knew?
  • Still, mssql_query worked well enough in "SQL Injection Mode", concatenating stuff from $_POST into the query text. This was reassuring, but not what I had in mind for the long run.
  • And then I found that my stored procedures, which ran nicely enough in SQL Server Management Studio, wouldn't execute with PHP's mssql_execute.
  • There's always Google, and somebody helpfully explained that one must set the version to 8.0 in /etc/tds.conf. Gee, how did I miss that? I edited the file, and just like that, the stored procedures worked as intended.
  • Until I rebooted after squeezing down memory, and mssql_connect quit working. Eventually I worked out that the httpd server needed to have LD_LIBRARY_PATH set.
By the time I was done, and had written up instructions for the other team, I was tired and distracted. When I spoke to one of them and she changed the topic, it took a moment to catch up.

Yet having said that, I have to acknowledge how much simpler it is to set up a Linux machine now. Fedora and VMware/VSphere take so much of the pain out of installation, and no doubt other distros are comparably good. To one who can remember the monitor shaking and chuffing as XFree86 tried to evaluate it, this seems like magic.

No comments:

Post a Comment