oci8

Tag archives:

Apache, PHP, Snow Leopard and Oracle conspired to kill me, but I didn’t let them!

In a nice epilogue to my post about how Apache, PHP, Zend Debugger and Snow Leopard are conspiring to kill me, I have good news!

Thanks to Zend’s release of a 64-bit version of the Zend Debugger for Mac OSX, I finally got to get everything working together nicely in 64-bit world.

I ended up doing a complete format and re-install of Snow Leopard, since I had too many 32-bit binaries laying around. This gave me a great opportunity to clean up my computer too. Double win!

Along the way, I had a couple of hurdles…

  • iconv continued to throw defined symbol errors. Tried manually compiling iconv in 64-bit but that didn’t work, eventually just went with a Macports install and that worked. Also, tacked “-liconv” to the end of my EXTRA_LIBS in the Makefile. For good measure.
  • Tacked “-lresolv” to the end of EXTRA_LIBS in the Makefile too, thanks to this handy PHP on Snow Leopard reference
  • I used Macports to install the GD related stuff, since the native OSX build of PHP references were broken
  • We use Oracle as a backend at work, and I had gotten the Oracle Instant Client working on my Leopard build but was having a hell of a time getting it working on Snow Leopard.

All of this repeated many times over the past couple of days, trying to get OCI8 to work properly:

  • Downloaded the Instant Client Basic, SDK and SQL*Plus from Oracle
  • Unpacked them all into /opt/oracle/instantclient_10_2
  • Recompiled PHP with “–with-oci8=instantclient,/opt/oracle/instantclient_10_2,10.2″
  • Got lots and lots of “PHP Warning: ocilogon(): OCIEnvNlsCreate() failed. There is something wrong with your system – please check that DYLD_LIBRARY_PATH includes the directory with Oracle Instant Client libraries”
  • Tried setting the environment variables via
    • Bash shell
    • /etc/profile
    • SetEnv in the Apache configs
    • putenv() on the script
    • Voodoo

    But none of it worked.

The problem was that I had made the decision to use the default install of Apache that came with OSX, which has ever so slightly different rules associated with it.

Eventually, I found out about plist files, and how OSX’s Apache ends up caring about them. So a quick addition to /System/Library/LaunchDaemons/org.apache.httpd.plist and an Apache restart later and my DYLD_LIBRARY_PATH woes were over!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Disabled</key>
    <true/>
    <key>Label</key>
    <string>org.apache.httpd</string>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/sbin/httpd</string>
      <string>-D</string>
      <string>FOREGROUND</string>
    </array>
    <key>OnDemand</key>
    <false/>
    <key>SHAuthorizationRight</key>
    <string>system.preferences</string>
    <key>EnvironmentVariables</key>
    <dict>
      <key>DYLD_LIBRARY_PATH</key>
      <string>/opt/oracle/instantclient_10_2</string>
      <key>TNS_ADMIN</key>
      <string>/opt/oracle/tns</string>
    </dict>
  </dict>
</plist>

By adding lines 19 to 25, the environment variables given are passed along to PHP via Apache and eventually the Oracle Instant Client.


Other than the OCI issues, the recompiling of PHP went smoothly. Of course, this is in large part thanks to what I learned on my previous adventures in PHP OSX compilation. I’d still like to know more about .plist files, but for now, I’m happy that I’m back up and running where I need to be.