Can't get php-odbc to install

Keywords: LAMP/MAMP/WAMP - AWS - Technical issue - Other

bndiagnostic ID: 0a4a7910-4c49-d04e-d847-a86605373eb6

bndiagnostic output:

? Apache: Found possible issues
? Processes: Found possible issues

bndiagnostic failure reason: The diagnostic tool showed an apache error that was related to a hacking attempt (someone trying to access a password file from the web), and also said that apache, php, and mysql are not running, but they clearly are, I am using them and they are all running. Also none of the links for the diagnostic tool took me to a working page, I had to google it and manually install it even though my stack is only about a year old and according to the documentation all stacks have it installed since 2017.

I am on LAMP 7.4.10 in an AWS lightsail server. I’m trying to use odbc to connect to some data on an as400 using php. I have the driver installed and can connect using this driver and get data from a command line. Now I am trying to create a php script to connect and get data.
My first line of my php script is

$conn = odbc_connect("drivername","username","password");

When I run this from the command line I get the error:
PHP Fatal error: Uncaught Error: Call to undefined function odbc_connect()
I looked this up and it seems PHP 7 doesn’t include ODBC, so I installed php-odbc as follows:

sudo apt update
sudo apt install php-odbc

Then I tried to edit php.ini and uncomment extension=odbc
When I do this, I get the error:

PHP Warning:  PHP Startup: Unable to load dynamic library 'odbc' (tried: /opt/bitnami/php/lib/php/extensions/odbc (/opt/bitnami/php/lib/php/extensions/odbc: cannot open shared object file: No such file or directory), /opt/bitnami/php/lib/php/extensions/ (/opt/bitnami/php/lib/php/extensions/ cannot open shared object file: No such file or directory)) in Unknown on line 0

I looked at the Debian site and found that it installs this extension in /usr/lib/php/20180731
When I look there, I see the file.
So I tried the full path to this file in php.ini, and I get the following error:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20180731/' (tried: /usr/lib/php/20180731/ (/usr/lib/php/20180731/ undefined symbol: php_error_docref0), /opt/bitnami/php/lib/php/extensions//usr/lib/php/20180731/ (/opt/bitnami/php/lib/php/extensions//usr/lib/php/20180731/ cannot open shared object file: No such file or directory)) in Unknown on line 0

This is where my capabilities end. I’ve rebooted the whole server, restarted apache, restarted php, etc. I’m not sure what else to try. I just need to be able to use odbc in php scripts on this server. Any idea how to get this installed so that it works?

I also tried PDO but when I do


I only see sqlite and mysql, I don’t see my ODBC driver, so I’m not sure how to use PDO without being able to use from the php-odbc install.

Hi @dkersten,

Thank you for using our solution. Please note that our packages are built from scratch and they do not use the system’s packages to run.

You are installing the php-odbc package that is not used by the Bitnami’s installation, that’s why you can’t use it. Enabling ODBC in PHP requires recompiling the component from source and enabling different flags and that’s not something we plan to do in the short term.

Sorry for the inconvenience.

Do you know of an alternative way to use ODBC as a data source on this server? In bitnami’s WAMP server you simply have to set the extension to the dll, but for the Bitnami LAMP I don’t see any ODBC extension, or even odbc for PDO.

Hi @dkersten,

Maybe this thread can help you further:


Every time I have been using ODBC it is to connect to a legacy database through a DSN to allow sql querying. I understand that today the most common use for it is to connect to Microsoft products like Access, but in my world it is always to connect to some kind of database for an ERP system such as on an AS400, or a C-ISAM database in an old Unix Cobol environment. If I had MySQL connectivity, I wouldn’t need ODBC. In this case, I am connecting to an AS400 database using the IBM iSeries ODBC driver for Linux.

I solved the issue by spinning up a new AWS server with vanilla Debian, then manually installed PHP, Apache, and MySQL, then installed the php-odbc and unixodbc modules, and now I can use odbc_connect in my scripts and it is working great. I also has used a Bitnami WAMP stack on my local machine and it worked as well, since I only had to uncomment the extension for odbc and point it at the existing dll in the php.ini file. But WAMP is slow, so I went the Linux route and built the stack by hand and it is about 6-10 times faster than the WAMP stack. It’s a shame that Bitnami doesn’t support ODBC in their LAMP stack, but now that I know this I know what to do for future company acquisitions where all we have is an ODBC connection to the legacy database. Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.