问题
I have a php script who ask data from a odbc database (pervasive client).
When i run the script in CLI as the psql user (which the installer created) , then i have no problems and the script runs.
When i run the script in browser ( as www-data) or in CLI as root or as a cronjob then i receive the error :
PHP Warning: odbc_connect(): SQL error: [unixODBC][Driver Manager]Can't open lib '/usr/local/psql/lib64/libodbcci.so' : file not found, SQL state 01000 in SQLConnect in /var/ww....
i have added the user www-data & root in the groups that the pervasive client has installed.
Everything runs on a Debian server.
回答1:
Solution, as revealed in comments --
Set the environment variables for each user and process that needs to perform the task, to match the environment that was active for PHP and the psql user.
This was achieved by using a shellscript for the full task.
来源:https://stackoverflow.com/questions/50755773/odbc-connect-runs-only-with-psql-user