1

Does anyone have a clue on how to install the Microsoft SQL PDO PHP Driver in OpenLiteSpeed? I've searched and searched and found nothing.

Preferably PHP7.4 but if you know of how to do this in any 7.x it should work.

Thanks!

  • I don't know much about openlitespeed, but according to https://openlitespeed.org/kb/default-php-settings-for-openlitespeed/, PHP is not hosted within openlitespeed, rather it's just called as an executable. So, logically from that we can see that any installing of PHP components will be unrelated to openlitespeed itself. I suspect you're better to search for instructions for how to install that driver on your specific operating system. See https://learn.microsoft.com/en-us/sql/connect/php/loading-the-php-sql-driver?view=sql-server-ver15 for details. – ADyson Sep 15 '21 at 22:32
  • @ADyson - Yes and no? OLS uses it's own compiled version of php "LSPHP" so trying to call normal install methods for php drivers do not work. – Kevin Justice Sep 16 '21 at 12:08

1 Answers1

1

To get pdo_sqlsrv, we can use PECL Extension For LSPHP.

  1. Install pear package
sudo apt-get install lsphp74-pear -y
  1. Install development files for programs that will use the unixODBC library
apt install unixodbc-dev -y
  1. Set up a soft link from lsphp74 to PHP
ln -s /usr/local/lsws/lsphp74/bin/php /usr/bin/php
  1. pecl install
pecl install pdo_sqlsrv

You should see output like this if build successfully.

Build process completed successfully
Installing '/usr/local/lsws/lsphp74/lib/php/20190902/pdo_sqlsrv.so'
install ok: channel://pecl.php.net/pdo_sqlsrv-5.9.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=pdo_sqlsrv.so" to php.ini
  1. Add the compiled file to the php.ini
echo 'extension=pdo_sqlsrv.so' >> /usr/local/lsws/lsphp74/etc/php/7.4/litespeed/php.ini
  1. After enabling the extension in php.ini, restarting the web service is required for the changes to be picked up.
systemctl restart lsws
Eric
  • 732
  • 4
  • 13
  • Thank you so much! This is not documented anywhere that I found. Compiling now! – Kevin Justice Sep 16 '21 at 12:10
  • No problem. Since there're too many extensions, LS offers some common packages. To build other packages, we can also follow https://docs.litespeedtech.com/extapp/php/extensions/#the-pear-package-manager which shows some basic command. – Eric Sep 17 '21 at 00:17
  • Also had to use this to work around pecl issue: https://stackoverflow.com/questions/15692349/pecl-install-apc-isnt-working-shtool-does-not-exist – Kevin Justice Sep 18 '21 at 00:06
  • Thanks for sharing, I did not hit this though. – Eric Sep 19 '21 at 12:53