Proper setup of Oracle Environment variables for PHP, MDB2, and OCI8 - php

I've set up a Fedora 19 server, with Oracle 11g, PHP 5.5.4, Apache 2.4.6, and PEAR 1.9.4. In addition to this, I have the OCI8 plug-in for PHP downloaded and enabled, and have downloaded MDB2 and the MDB2_Driver_oci8.
However, there are problems with the setup - an old website from an older server doesn't work on it, so it seems the culprit is an improperly setup Oracle environment for Apache, and oci8.
The Oracle 11g Database itself, however, works fine - I've been able to log in as SYSTEM, create a new user, and restore a database to said user.
Below is a screenshot from the Environment of the new Fedora 19 server, using phpinfo():
Below is a screenshot of the Environment of the older Fedora server:
There's a lot, but probably the only important things there are the ones concerning Oracle.
I followed link here tutorial on how to install Oracle 11g on Fedora, and I was able to get it up and running, albeit I have to run . /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh every time I start up.
But whereas in the old server, it shows up in the Environment (in phpinfo()), in the new server, it does not.
Of note is that LD_LIBRARY_PATH is set in both, but I had to to add it manually in the httpd file (/etc/sysconfig/) by adding the following in it:
LD_LIBRARY_PATH="/u01/apps/oracle/product/11.2.0/xe/lib export
LD_LIBRARY_PATH
But if I echo out LD_LIBRARY_PATH in the newer server, it returns nothing. In the older server, it returns what is displayed in the Environment page.
What's going on here? How do I fix this? And is there any other Oracle-related thing I missed?
Thanks to any and all who will help.

Related

Unable to load dynamic library 'php_oci8_19.dll'

Hy! I'm trying to use oci on windows, I found some linked issues, but I don't have any xampp, or apache, or anything, I'm only using the php built-in server. I enabled the oci extension in the php.ini file, but it does not work. I was looking for answer. I don't need any oracle database, there is a database, I only want to connect it with my app. I have the error above every time, when I'm trying to run any php command. So it does not work. The missing dll file is there, so I don't understand, why is it missing. I installed pear, and pecl, but pecl installations need openssl, openssl needs visualC++ and some other things... is there any other solution? Even though why does it not find that dll, if it's there... I downloaded Oracle Instant client and Oracle SDK, I unzipped it, set the environmental variables, but nothing changed... Please, help!
You need to download the correct oci8_19.dll if not already there and placed it under your_xampp_directory\php\ext folder.
Enable/add this extension in your php.ini file.
Add environment variable path for PHP.
Then, you also need Oracle Instant client to load/run this properly. Download it from here. Be mindful about x86 or x64 architecture of your windows machine and download the one that matches your machine specs.
Add this Oracle instant client path too in your environment variable.
Restart command prompt and type php -v. Voila! It runs smoothly and shows you just the PHP version, which means your oci extension loaded properly.

Reset Apache PATH environment variable in Windows

I recently upgraded Apache and PHP due to security, and I also use PHP to communicate with Oracle databases. The new PHP version only has php_oci8_12c.dll module, so I also installed Oracle 12c client.
After I enable the oci8 module, I noticed the module doesn't show up in Apache when I run phpinfo(), but if I run php -m, I find the oci8 module there. Further checking revealed that the PATH environment variable has not been updated since the upgrade, and that the new path only get appended at the end of the PATH variable.
I paste below the (stripped-down) PATH data from Apache:
C:\oracle\client11gR2_32\bin;C:\www\Apache24\bin;C:\www\php548;C:\database\mysql5528\bin;C:\oracle12c\client12c_32\bin;C:\www\php562;C:\www\php562\ext
Compared with system PATH variable:
C:\oracle12c\client12c_32\bin;C:\oracle\client11gR2_32\bin;C:\www\Apache24\bin;C:\www\php562;C:\www\php562\ext;C:\database\mysql5528\bin
I tried restarting the Apache service, and also uninstall/reinstall, but none works. It seems that the data somehow get 'cached' in a separate location, but I can't tell where. If I renamed the Oracle client 11g HOME folder, then the oci8 module is detected and loaded in Apache.
I've searched all around the internet for 'resetting' the Apache PATH variable, but to no avail, therefore I post it here. Please help.
There are two possible reasons I can think of:
The path to the 12c client is a user variable, not a system variable (but then I would expect it to be at the end of the path list)
The 12c client installer has directly modified the registry to add the path, and therefore the system environment has not recognised the change yet. (If you are running Apache as a service then just because your account can see the path change doesn't mean the SYSTEM account can see the change.)
Assuming the latter case, a server reboot would fix the problem. If you can't reboot the server then you can try stopping Apache, opening the Environment Variables dialog, and simply pressing OK (on this and all parent dialogs) to 'reinitialise' the system environment. Start Apache again and it should pick up the new setting.
On a related note: You should really replace the bundled OCI driver (1.4.10) with the most recent build from PECL (currently 2.0.8). As stated in the PECL description:
Use the older PHP OCI8 1.4.10 when using PHP 4.3.9
through to PHP 5.1.x, or when only Oracle Database 9.2 client
libraries are available.
The Windows download contains php_oci8.dll, php_oci8_11g.dll, and php_oci8_12c.dll. So you wouldn't have needed to try changing the Oracle client installation.

PHP, IIS, Oracle (OCI) not working

We are migrating from a Windows SBS 2011 to Windows Server 2012 R2.
We have an internal website that connects to our Oracle database using PHP.
I am trying to migrate this to the new server and so far I have:
Installed IIS Server Role
Installed PHP
Downloaded Oracle Instant Client to C:\instantclient
Added C:\instantclient to PATH System Variable
Added php_oci8.dll to php.ini and checked that PHP is actually using this php.ini
Restarted server
I am still getting error messages like oci_ commands not being recognised etc.
I'm lost. I've searched online and the instructions match what I have done from memory.
I haven't found a single thing online that I haven't done.
Depending on the version of InstantClient you have installed you might need to include the bin folder in the path, like so:
C:\instantclient\bin
To check if the DLL files are available in the path enter where oci*.dll in a command prompt. It should return a list of matching files.
Also, remember that just because your account can see the DLL files doesn't mean IIS/PHP can. That runs under a different account that might not have permission to access the files. Check your IIS error log and PHP php_errors.log file for any specific error messages.
Edit
After a rather lengthy chat, the problem was resolved by:
Updating the InstantClient from 10.1.0.5 to 10.2.0.5 (as mentioned in the module requirements: On Windows, the php_oci8 DLL needs Oracle client libraries from version 10gR2 or greater.)
Adding a copy of msvcr71.dll to the InstantClient folder.
Downloading and manually configuring PHP from php.net instead of using PHP Manager for IIS.
Ensuring the Path environment variable correctly pointed to the InstantClient and PHP folders.
try this:
extension=php_oci8_12c.dll
(instead of php_oci8.dll) - that is what I am using and you probably downloaded the same instant client as I did.

php odbc_connect to mssql works in linux/ubuntu command line not browser

I really feel like I have done an exhaustive search on this matter, found similar issues and have tried a number of things without success, so I am for the first time posting a question here:
I do a lot of web pages/web programming (PHP/jQuery mostly) and host these pages on my digital library department's Drupal/Ubuntu Server. I just code them and post them via Dreamweaver, as I don't have much use for the Drupal front end. I just need the server for my pages.
Anyway, I am wanting to make some PHP pages that can connect to our library catalog, so I have been working from the command line of the Drupal/Ubuntu server. I installed unixODBC, had some troubles, installed FreeTDS, set up the drivers and the DSN.
Finally...
I was able to get a connection to our catalog via tsql and run a query.
I made a basic PHP script to test the connection:
It works from the Ubuntu command line of the server (connection successful).
It doesn't work when I load it in a browser. I get the dreaded:
Warning: odbc_pconnect(): SQL error: [unixODBC][Driver Manager]Data source name not found, and no default driver specified, SQL state IM002 in SQLConnect in /var/www/mydirectory/mytestpage.php on line 15
UPDATE: I installed a test Ubuntu Server in a partition on my laptop, where I started clean, installed Apache2/PHP5(with mssql and odbc modules, etc)/FreeTDS, etc. I got a tsql connection. I made the basic PHP script and ran it successfully from the command line. Then I navigated to the php page from a browser and it worked! I still need to get this to happen on the Drupal server version, but now I have at least narrowed down the issue to something on the Drupal server.
I searched and found such possible causes as:
File permissions, which I think I got corrected, but no go
That maybe I had set up a User DNS and not a System DNS which I tried my best to correct with the proper "odbcinst" command options
That maybe php needs to be running in CGI mode instead of as a module. But that seemed unlikely from what I read. And I am not sure how that would affect Drupal. (There are limits to the system wide changes I should make here.)
A number of people said it was SElinux blocking Apache from displaying the page in the browser, but temporarily disabling SElinux didn't work.
Thanks for any assistance!
Check you have enabled the mssql.so etc at the following location
/etc/php5/apache2/php.ini, you will be having another at /etc/php5/cli/php.ini
in ubuntu php.ini will be maintained separately for cli & mod_php apache configuration
If you are going to test your odbc sources on the commandline, I would advise you use the isql utility instead of tsql. isql uses the DSN you defined in odbc.ini to connect to the database, while tsql connects directly to your database.
If it works with isql, it should work on your webpage as well.
Also check the Drupal/Ubuntu Server files /etc/odbc.ini (your DSN sources) and /etc/odbcinst.ini (TDS Driver settings) to see if they match the ones on the working Ubuntu installation.
My guess is it has something to do with the php. ini file. On my Ubuntu system I've got 2.
One in /etc/php5/apache2/php.ini
And one in /etc/php5/cgi/php.ini
The values in the apache2 path will need to be adjusted to allow the connection. Unfortunately outside of that I'm not too much use as I use MySQL and Mongo
Copy your php.ini from work server to non-work server, add make needed environment variables accessible before starting your web server, and make sure your web-server has full access to your odbc and odbcinst ini-files. And so, using mssql knowledge base or help.

Apache php 5.3 postgreSQL driver could not be loaded

I have set up a XAMPP installation on a windows server 2008 R2 that includes:
Apache 2
PHP 5.3.x
MySQL (not used anyway)
Then I have installed PostGreSQL 9.x. I have uncommented the pgsql pdo dlls in the php.ini file accordingly but when I try to connect to pgsql I get 'driver could not be loaded'. I am stuck as I couldn't come across a fix to that on the internet, I have tried adding the path of the pgsql installation (bin and lib dirs) to the PATH environement system but the problem persists. I have also rebooted the system many times after changing any configuration to ensure it is saved and applied but still same outcome.
I have read in a nonclear conversation that this might be related to the versions but couldn't find anything further.
If you have succeeded in performing the latter I would be greateful if you could provide me with some insight. (I am open to any alternatives except downgrading to older software versions).
Thanks so much for your time
Fixed by manually installing apache2 and php instead of going through xampp (or wampp). It seems those are buggy when it comes to the latest php version and pgsql pdo driver.

Categories