OK, so I have this terrible problem with oci, apache, php and suse. First off, versions:
PHP 5.3.15 (cli)
Apache/2.2.22 (Linux/SUSE)
OCI8 1.4.9
SUSE 12.2 32 bit
Oracle client 10.2.0.4
Problem
I have really simple php file:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
oci_connect('user', 'passwd', 'host/sid');
?>
When I run it from command line it executes fine:
machine:~ # php oci.php
machine:~ #
But when i run it in browser, it gives me:
Warning: oci_connect() [function.oci-connect]: OCIEnvNlsCreate() failed. There is something wrong with your system - please check that ORACLE_HOME and LD_LIBRARY_PATH are set and point to the right directories
Apache configuration
I've been struggling with this issue for some time now and I'm pretty sure my apache configuration is correct.
I export all required variables before any apache process is started - I added
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/oracle/home/lib; export LD_LIBRARY_PATH
ORACLE_HOME=/path/to/oracle/home; export ORACLE_HOME
TNS_ADMIN=/path/to/oracle/home/network/admin; export TNS_ADMIN
NLS_LANG=POLISH_POLAND.EE8MSWIN1250; export NLS_LANG
at the beginning of /etc/init.d/apache2 script (I start apache by /etc/init.d/apache2 start).
Apache runs from wwwrun user, who is in oinstall and dba groups:
machine:~ # cat /etc/apache2/uid.conf
User wwwrun
Group www
machine:~ # id wwwrun
uid=30(wwwrun) gid=8(www) groups=8(www),113(oinstall),114(dba)
machine:~ # l $ORACLE_HOME
total 216
drwxr-xr-x 48 oracle oinstall 4096 Jan 25 17:07 ./
drwxrwxr-x 3 oracle oinstall 4096 Jan 25 17:01 ../
...
machine:~ #
Possible problem
I don't have any environmental variables in Environment section in phpinfo(); output - could this be the problem? If yes, how can I fix this? Is it some kind of security issue? I've read about problems like that with SELinux enabled, but I don't have it, my firewall is off.
Solution?
Any help would be greatly appreciated!
Problem solved! Thanks to these (Setting the Oracle Environment section) instructions and ken_yap's answer to this thread.
To put variables in Apache's Environment section you just have to add them in /etc/sysconfig/apache2 file: LD_LIBRARY_PATH=/path/to/oracle/lib.
Another solution ( that do not need root access ) is to add this lines in the php page:
putenv("ORACLE_HOME=/opt/app/oracle/product/11.2.0/db_1");
putenv("LD_LIBRARY_PATH=/opt/app/oracle/product/11.2.0/db_1/lib:/lib:/usr/lib");
Regards
For Debian users - edit file
/etc/apache2/envvars
on the end of file add link to your OCI library - eg.
export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2
Another approach for Centos 7 with nginx
$ sudo vim /etc/ld.so.conf.d/oracle-instantclient.conf
// Add path to oracle client lib, the XX is the version, ex: /usr/lib/oracle/XX/client64/lib
$ sudo ldconfig
$ sudo service php-fpm restart
Done!
Related
ubuntu 16.10 / nginx / php7.0 / oracle 11 xe
I'm trying to connect to the Oracle databas via PHP. And I get the following errors.
$conn = oci_connect('login', 'pass', 'localhost/xe');
Warning: oci_connect(): OCIEnvNlsCreate() failed. There is something
wrong with your system - please check that ORACLE_HOME and
LD_LIBRARY_PATH are set and point to the right directories in
/var/www/blah.php on line 26
Warning: oci_connect(): Error while trying to retrieve text for error
ORA-01804 in /var/www/blah.php on line 26
Really request variables, they will be empty. This code return empty string.
$test = getenv('LD_LIBRARY_PATH')." ".getenv('ORACLE_HOME');
print ("$test");
But in phpinfo() they are displayed.
I can write environment variables to each file, but this is not an option.
putenv("ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe");
putenv("LD_LIBRARY_PATH=-Wl,-rpath,/u01/app/oracle/product/11.2.0/xe/lib -L/u01/app/oracle/product/11.2.0/xe/lib -lclntsh");
What can I do?
I solved it by removing semicolon from the line ;clean_env=no in the file /etc/php-fpm.d/www.conf in case of php-fpm 5.6 in CentOS 6. Hope it will help in newer PHP versions. Remember to restart php-fpm service after making changes to this file.
We dont have the same infrastructure but I just solved this same issue in :
Apache
CentOS7
PHP 5
Oracle 12cR1
The message says :
please check that ORACLE_HOME and LD_LIBRARY_PATH are set and point to the right directories
In apache, there is a file where you can set the environment variable :
/etc/sysconfig/httpd. There has to be a config file for nginx.
I added the required environment variables.
Assuming that
ORACLE_HOME is /oracle/product/12.1.0/dbhome_1
Oracle client was installed under /oracle/product/12.1.0/client
Add :
ORACLE_HOME=/oracle/product/12.1.0/dbhome_1
LD_LIBRARY_PATH=/oracle/product/12.1.0/dbhome_1/lib:/oracle/product/12.1.0/dbhome_1/network/lib:/oracle/product/12.1.0/client/lib
I also added :
TNS_ADMIN=/oracle/product/12.1.0/dbhome_1/network/admin
ORACLE_SID=<your sid>
After updating /etc/sysconfig/httpd I just restarted Apache's service httpd and that was it:
$ sudo systemctl restart httpd
I hope it helps !
This is related to the incorrect NLS_LANG parameter. It was set to 'NA' in my case. The fix is:
Windows - The NLS_LANG must be unset in the Windows registry (re-named is best). Look for the NLS_LANG subkey in the registry at \HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE, and rename it.
Linux/UNIX - Here you simply issue the Linux command "unset NLS_LANG"
I can't use the ldap_connect function but I checked in php.ini and it's in.
I didn't find this error on Internet. Everyone is having "Call to undefined function" but I got "Attempted" and can't figure why.
I checked with function_exists('ldap_connect') and it was false.
I use Symfony2, apache and PHP 5.5.9.
I call the function from my controller and I get the parameters from parameters.yml :
$ldap_user = $this->container->getParameter('ldap_user');
$ldap_pass= $this->container->getParameter('ldap_pass');
$ldap_co = ldap_connect($this->container->getParameter('ldap_address'));
If someone could help me that would be awesome.
Thanks in advance.
I think I find the answer. It was an apache2 issue.
I went in /etc/apache2/mods-available to check if ldap.conf and ldap.load were in, and they were. Then I checked in /etc/apache2/mods-enabled in which they were not. And that's the problem.
So I ran the following command : sudo a2enmod ldap in order to activate the ldap module for apache2. Then sudo service apache2 reload and in the instant I saw it enabled in phpinfo().
Maybe that's not the correct way to do it, if anyone have a better answer I'll take it.
You need to enable ldap extension to php. To do that (paths are from Ubuntu) add symbolic link /etc/php5/apache2/conf.d
lrwxrwxrwx 1 root root 31 Sep 23 2014 20-ldap.ini -> ../../mods-available/ldap.ini
(similar to /etc/php5/cli/conf.d if you want to have this available in cli)
Check doc for more info
I'm trying to install PHP LDAP Admin, http://phpldapadmin.sourceforge.net , on a RHEL 6 server. I have the files in place and Apache virtual host directive configured to htdocs.
The error I'm getting is:
Notice: Undefined variable: _SESSION in /path/to/pla/lib/page.php on line 381 Fatal error:
Call to a member function getValue() on a non-object in /path/to/pla/lib/page.php on line 381
PHP (5.4.13) is running on the server, and sessions are not a problem elsewhere. I cloned my git repository to an OSX development box and it works there. I double checked and session_start() is called.
If httpd is running under apache group:
chgrp apache /etc/phpldapadmin/config.php
I had the same problem and finally i solved it just placing config.php
in the correct folder (phpldapadmin/config)...really silly mistake
I had the same problem (ubuntu 14.04).
I changed the permissions on usr/share/phpldapadmin/config.php and that solved the problem.
This has already been answered by harveyzh but this answer is for linux-noobs like me :)
Happens in most cases after update
and apache (or php5-fpm!) didn't run with default users.
Just add the user wich is running Apache2 (or php5-fpm!) to the system group "www-data" (debian) and restart services apache AND if used php5-fpm both.
Get the User apache is running as:
~# sed -rn 's/^User (.+)/\1/p' /etc/apache2/apache2.conf
Remember:
Changing permissions to repo maintained files is a bad idea.
This takes effect only until the next update fixes them back to default...
I had also same problem where we have just changed the group name for phpldapadmin config.php file. It worked for me.
chgrp apache /etc/phpldapadmin/config.php
Use chgrp GNU command with the group name of apache2
In my case was: www-data
So you need to do like that:
chgrp www-data /etc/phpldapadmin/config.php
to find group name of config.php you should use ls -l command line and take the fourth column
I installed php5-intl on my osx lion.
It seems to work properly on command line mode because if I try to run the following script (1):
$fmt = datefmt_create( "en_US" ,IntlDateFormatter::FULL,IntlDateFormatter::FULL,'America/Los_Angeles',IntlDateFormatter::GREGORIAN );
echo "First Formatted output is ".datefmt_format( $fmt , 0)."\n";
> php -m |grep intl
intl
> php test.php
First Formatted output is Wednesday, December 31, 1969 4:00:00 PM Pacific Standard Time
But if I try to sun the same from my apache (after sudo apachectl restart) I get the following error:
> tail /private/var/log/apache2/error_log
PHP Fatal error: Call to undefined function datefmt_create() in
P.S.:
I also added the following line to my php.ini
extension_dir = "/opt/local/lib/php/extensions/no-debug-non-zts-20090626"
ll /opt/local/lib/php/extensions/no-debug-non-zts-20090626
total 848
-rwxr-xr-x 1 root 261712 7 May 10:54 xdebug.so
-rwxr-xr-x 1 root 168912 31 May 19:53 intl.so
in php.ini is written: Loaded Configuration File /private/etc/php.ini which is the file I edited.
Other info on my configuration are the following:
/private/etc/apache2/httpd.conf
LoadModule php5_module libexec/apache2/libphp5.so
/usr/libexec/apache2/libphp5.so
/private/etc/php.ini
extension_dir = "/opt/local/lib/php/extensions/no-debug-non-zts-20090626"
Create a web page, with these contents:
<?php
phpinfo();
echo datefmt_create("en_US" ,IntlDateFormatter::FULL,IntlDateFormatter::FULL);
?>
(Yes, I know that 2nd line gives an error, but in this case it is enough to tell us it works.)
View that web page, and search for "Internationalization support" or "intl". In my case I see:
Internationalization support enabled
version 1.0.3
ICU version 4.2.1
Directive Local Value Master Value
intl.default_locale no value no value
intl.error_level 0 0
If you have no intl section present, then it can only be a php.ini issue (the more usual cause is not restarting apache, but you said you'd done that).
To confirm, edit the php.ini file again and at the very end introduce a change you can be sure will work. E.g. asp_tags = 1. Now reload your phpinfo() page and make sure you see the change there.
If you don't perhaps it is permissions; the user Apache runs as cannot read your php.ini file?
I am getting both modules listed as installed / configured when I use:
php -m
or if I use:
php -i
but when I use:
$m = new Memcache;
// or
$m = new Memcache();
// or
$m = new Memcached();
//or
$m = new Memcached;
I get the following error:
Fatal error: Class 'Memcached' not found
I am running on a Mac - OS X (10.5.7) with default install of apache & php. Additionally, I have memcached running as a daemon on 127.0.0.1:11211 and libmemcache as required by the php-memcached library. I have restarted apache tons of times and even done a machine restart.
Does anyone know why the modules/extensions show up in the command line but not in my phpinfo()? I am literally stumped, after 3 hours of googling, I am just about ready to give up.
Also, please note, my phpinfo() outputs my ini files as follows AND they are both the exact same file:
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /private/etc/php.ini
UPDATE:
Apache is failing to load the extension.
[Fri May 14 04:22:26 2010] [warn]
Init: Session Cache is not configured
[hint: SSLSessionCache] PHP Warning:
PHP Startup: Unable to load dynamic
library
'/usr/lib/php/extensions/no-debug-non-zts-20060613/memcached.so'
- (null) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load
dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20060613/memcache.so'
- (null) in Unknown on line 0
Does anyone know why or how this would happen? Both of the files referenced above DEFINITELY ARE there. Should I move this question to server fault?
Your webserver is probably using mod_php, which is a seperate bit of code from the standalone (CLI) interpreter. If they are both using the same ini file, and the memcache extension is configured in the ini file, then it sounds like for some reason, the mod_php is failing to load the extension - check your webserver error_log for startup errors.
It may be that the mod_php was compiled without memcache support (most extensions need to have a stub file linked into the php code, even though the bulk of the code is not linked until run time). Or it may be a permissions problem on the shared object file. Or your webserver may be running chroot, and unable to find the extension (which would also mean that although the ini files appear to have the same path, this is relative to different roots).
HTH
C.
because both versions use different php.ini
place your php.ini into location noted in the phpinfo() outout
I would suspect that the issue revolves around permissions. When you run php from comand line, it runs as the user invoking it. When run as an apache module, it runs as "nobody".
I would assume that the memcached.so file, or the directory it's in does not have proper permissions.
I stumpled upon this post and was having the exact same problem with an extension in my php -i but not in phpinfo(). Mine was a permissions problem because of selinux on a CentOS machine. I had to change ownership and permissions and now it is working as expected.
Set php path in environment variables as given below.
Right-click on "My Computer"
Properties
Advanced Tab > Environment Variables
Under System variables, scroll down to find "Path", select and click on Edit.
Add path to your php install on the end (make sure to precede with semi-colon ";"). Example: ";C:\php7"
Click Ok.