Connect to external SQL Server from LAMP Packaged Linux

Keywords: LAMP/MAMP/WAMP - Installers - How to - Plugins installation/configuration

Description:
Hi all,

I have followed this installation Install Modules PHP - MSSQL to connect to a remote MS SQL Server 2019 Database. However, I have found that the system is working in my Ubuntu 20.04 LTS when I am starting everything by console, but not in the LAMP packaged Bitnami.

I believe that the problem is that the version LAMP 8.0.11-3 that I have is a self-contained installation. Therefore, the installations in my machine are not the same as the Bitnami self-contained Packaged. However, even when the documentation said that they are going to explain the two options: “native Linux system packages (Approach A), or if it is a self-contained installation (Approach B).”, the Approach B is not explained in any of the pages that I have followed.

I got working the connection.php by terminal of my Ubuntu 20.04 LTS but when I am using the Apache and the PHP from the packaged I got a 5xx Error in the browser and the log in the php -v of the bitnami console is:

jairom@jairom-X455LAB:~/Documents/lamp$ php -v
PHP Warning:  PHP Startup: Unable to load dynamic library 'sqlsrv.so' (tried: /home/jairom/Documents/lamp/php/lib/php/extensions/sqlsrv.so (/home/jairom/Documents/lamp/php/lib/php/extensions/sqlsrv.so: cannot open shared object file: No such file or directory), /home/jairom/Documents/lamp/php/lib/php/extensions/sqlsrv.so.so (/home/jairom/Documents/lamp/php/lib/php/extensions/sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_sqlsrv.so' (tried: /home/jairom/Documents/lamp/php/lib/php/extensions/pdo_sqlsrv.so (/home/jairom/Documents/lamp/php/lib/php/extensions/pdo_sqlsrv.so: cannot open shared object file: No such file or directory), /home/jairom/Documents/lamp/php/lib/php/extensions/pdo_sqlsrv.so.so (/home/jairom/Documents/lamp/php/lib/php/extensions/pdo_sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 8.0.11 (cli) (built: Oct  5 2021 08:01:59) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.11, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.11, Copyright (c), by Zend Technologies

I hope you can help me, thank you a lot.

Hi community,

Ok, after looking a lot, I have found that the solution when we are working with a self-contained installation. If my normal console was not the case to solve this, I thought that it would be a way to go into the container (similar to docker) somehow. I found that there is an application calls use_lampstack which is going to upload the rcfile of the self-contained.

With this environment variables we could use the commands in the installation process without the sudo and then the system would install everything in the self-contained bitnami Package. With this change my version now accepts SQL Server connections!

Happy coding.

Thanks for sharing your solution :slight_smile: