Reputation: 31
I need to set an environment variable on my Mac so when Apache is run, and PHP/PDO loads the pdo_informix driver, it knows the location of the Informix Home directory. And I really have tired everything!
In /usr/sbin/envvars I have added: export INFORMIXDIR=/Applications/IBM/informix
In /System/Library/LaunchDaemons/org.apache.httpd.plist I have inserted:
<key>EnvironmentVariables</key>
<dict>
<key>INFORMIXDIR</key>
<string>/Applications/IBM/informix</string>
</dict>
I've tried: launchctl setenv INFORMIXDIR /Applications/IBM/informix
All to no avail.
I have added a PassEnv line to the apache global config. But when I restart the service I see:
root 589 ->apachectl restart
[Mon Aug 05 13:35:16 2013] [warn] PassEnv variable INFORMIXDIR was undefined
When I run my test .php page, the driver loads but complains as it cannot determine the DB locale. Error message:
[Mon Aug 05 12:56:23 2013] [error] [client ::1] PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE=HY000, SQLDriverConnect: -23101 [Informix][Informix ODBC Driver][Informix]Unspecified System Error = -23101.' ...
Can anyone tell me what I've missed?
Upvotes: 1
Views: 2521
Reputation: 31
I do hope no one has wasted time looking at this issue. I have been caught out by a predecessor who set up an alias for apachectl in /etc/bashrc!
It turns out I was not executing /usr/sbin/apachectl but, instead, /opt/local/apache2/bin/apachectl
This script imports /opt/local/apache2/bin/envvars and not /usr/sbin/envvars. Nor does it use launchctl... the explains why none of my steps to set the environment worked. Once discovered I got it working straightaway.
Sorry to have troubled you all.
Upvotes: 2