I am trying to setup a local development box. The box's on Linux Mint. Installed apache, php and mysql without any problem, then I proceeded to install Oracle Xpress Edition as my newest project requires.
Obtained the oci8.so
through pecl and modified php.ini
.
The problem is, everytime I reboot and tries to connect to oracle using oci_connect()
call, it will give me this error:
oci_connect() [function.oci-connect]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME is set and points to the right directory
I've already checked the ORACLE_HOME
at the time the error arises and it seems to contain the correct value.
Now, I can get around this problem by going to terminal and
$ su
$ apache2ctl stop
$ apache2ctl start
That's the ONLY way of getting it fixed (i.e. not sudo apache2ctl restart
, not sudo apache2ctl {stop,start}
, not su
apache2ctl restart
).
I know this is a minor problem and I could probably live with it. But if someone out there can point me on getting this work, I'd very much appreciate it.
It sounds like the init script that starts Apache doesn't have the correct environment variables set (the script probably lives somewhere in
/etc/init.d
). It works when you manually restart it, because your shell has theORACLE_HOME
set properly, which gets passed on to Apache.The solution is to modify Oracle's system startup script to set the
ORACLE_HOME
environment variable. It may even have some way to set external variables automatically (on Red Hat style systems, most init scripts source files in/etc/sysconfig
, so you should take a look into the init script to see if it sources files from somewhere. That way if you upgrade Oracle and that updates the init script, your changes won't get blown away).Another option is to set
ORACLE_HOME
in the apachehttpd.conf
or in the virtual host that uses it.Add:
to
httpd.conf
(or inside the virtual host config file/etc/apache2/hosts-enabled/...
)That has the advantage of not needing to mess up with system scripts.
I've seen it caused by SELinux. I had to temporarily disable SELinux to install the Oracle drivers, then when I rebooted, the Oracle drivers weren't loaded. The Apache logs indicated this with:
According to this helpful page, you can tell SELinux to permit the Oracle drivers with:
You can also take the more radical step of disabling SELinux entirely. In /etc/selinux/config, change "SELINUX=enforcing" to "SELINUX=disabled"