My server is centos7, I managed to setup apache,php7.1,oracle-instantclient18.3-basic and oci8 on it. OCI8 is working fine now when I run the code on CLI, it connects the db and fetches data, only with one warning (also appears on running php -v) :
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_oci.so' - /usr/lib64/php/modules/pdo_oci.so: undefined symbol: php_pdo_unregister_driver in Unknown on line 0
unlike when I open up the page via browser (on a client machine) I got this error:
Fatal error: Uncaught Error: Call to undefined function oci_connect() in /var/www/html/pcmapi/emp.php:5 Stack trace: #0 {main} thrown in /var/www/html/pcmapi/emp.php on line 5
phpinfo() returns:
oci8
OCI8 Support => enabled
OCI8 DTrace Support => enabled
OCI8 Version => 2.1.8
Oracle Run-time Client Library Version => 18.3.0.0.0
Oracle Compile-time Instant Client Version => 18.3
Directive => Local Value => Master Value
oci8.connection_class => no value => no value
oci8.default_prefetch => 100 => 100
oci8.events => Off => Off
oci8.max_persistent => -1 => -1
oci8.old_oci_close_semantics => Off => Off
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
I cannot actually recognize what causes the fatal error whether in apache or oci configuration and I find it strange that oci functions are working fine on cli but not apache. any help?
The solution is to make sure you are loading pdo.so before you load pdo_oci.so.
I do not know the exact configuration you are using, but on Ubuntu for example, I have the pdo_mysql.so loading after pdo.so by having these configuration files in the PHP's conf.d:
10-pdo.ini:
extension=pdo.so
20-pdo-mysql.ini:
extension=pdo_mysql.so
Notice that the file 10-pdo.ini will load earlier than 20-pdo-mysql.ini simply because of its file name.
Good luck.
The common issue is that Apache doesn't have the Oracle client libraries (e.g. Instant Client) in its library search path. The reason PHP works in command line is because your shell does have the library search path correctly set.
If you don't have other Oracle libraries on this computer then do:
sudo sh -c "echo /usr/lib/oracle/18.3/client64/lib > /etc/ld.so.conf.d/oracle-instantclient.conf"
sudo ldconfig
If you do have other software that would conflict, then do something like edit /etc/sysconfig/httpd and add:
LD_LIBRARY_PATH=/usr/lib/oracle/18.3/client64/lib
Depending on your Apache version, how you set the environment varies (yay!)
You may or may not need to export this:
export LD_LIBRARY_PATH=/usr/lib/oracle/18.3/client64/lib
On other systems you can use Apaches envvars file.
Thanks for your time, I actually did reinstall all the environment over again, this was painful as its a production server but paid back..
while I had mysql & instantclient already setup, I removed php & httpd then reinstall them all as the following:
yum install httpd php php-mysql php-devel php-oci8 php-pear mod_ssl
and then:
service httpd restart
now it works.
Related
I'm running Mac OS X with Mojave and default Apache and PHP.
I'm trying to connect to a PostgreSQL with SSL/TLS, but are getting the error:
Warning: pg_pconnect(): Unable to connect to PostgreSQL server: sslmode value "require" invalid when SSL support is not compiled in in ..
However, running pg_config --configure does show the '--with-openssl' flag.
Running phpinfo however shows under pgsql that SSL is disabled.
But directly from the terminal I am able to use command line psql with SSL.
I was also stuck on the same issue, here's how I solved it
The default PHP of MacOS 10.14 (Mojave) doesn't have SSL enabled in its php pgsql extension
To manually install SSL certificate into the php pgsql extension would be possible but
troublesome
Instead, you can install a new version of php, which would indeed install all it's extensions again also with a php postgres extension with ssl enabled
First install homebrew if you don't have it, then install php as shown below
I installed php 7.3, as I had Catalina it came with 7.3.11 (it got upgraded to 7.3.21)
brew update
brew install php#7.3
brew link php#7.3
If you updated Mojave to Catalina, you may want to also add this after the above is done
brew link php#7.3 --force
After the above is done you just need to link it to your $PATH which can be done as:
echo 'export PATH="/usr/local/opt/php#7.3/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php#7.3/sbinbin:$PATH"' >> ~/.bash_profile
If you updated Mojave to Catalina, instead of the above do this
(since Catalina changed default shell to Zsh)
echo 'export PATH="/usr/local/opt/php#7.3/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/php#7.3/sbin:$PATH"' >> ~/.zshrc
Reload the terminal or open a new one, type in
php -v (the version should be changed)
And then type php -i, goto pgsql section
pgsql
PostgreSQL Support => enabled
PostgreSQL(libpq) Version => 12.3
PostgreSQL(libpq) => PostgreSQL 12.3 on x86_64-apple-darwin19.4.0, compiled by Apple
clang version 11.0.3 (clang-1103.0.32.59), 64-bit
Multibyte character support => enabled
SSL support => enabled
Active Persistent Links => 0
Active Links => 0
Directive => Local Value => Master Value
pgsql.allow_persistent => On => On
pgsql.auto_reset_persistent => Off => Off
pgsql.ignore_notice => Off => Off
pgsql.log_notice => Off => Off
pgsql.max_links => Unlimited => Unlimited
pgsql.max_persistent => Unlimited => Unlimited
You should see SSL support enabled.
When I ask the drush status while im in the folder of the website I get this message
/volume1/web/drupal8 $ drush status
PHP Fatal error: Undefined class constant 'MYSQL_ATTR_SSL_CA' in
phar:///usr/local/bin/drush/lib/Drush/Sql/Sqlmysql.php on line 56
Fatal error: Undefined class constant 'MYSQL_ATTR_SSL_CA' in
phar:///usr/local/bin/drush/lib/Drush/Sql/Sqlmysql.php on line 56
Drush command terminated abnormally due to an unrecoverable error.
[error] Error: Undefined class constant 'MYSQL_ATTR_SSL_CA' in
phar:///usr/local/bin/drush/lib/Drush/Sql/Sqlmysql.php, line 56
When I ask the drush status while im in the bin folder drush seem to work
/bin$ drush status PHP configuration : /etc/php/php.ini PHP OS
: Linux Drush script : /usr/local/bin/drush Drush
version : 8.1.5 Drush temp directory : /tmp Drush
configuration : Drush alias files :
I can't figure out what im doing wrong, how can I run drush on folder /volume1/web/drupal8?
thanks in advance
PDO is installed and enabled. I run php56 -i
PDO PDO support => enabled PDO drivers => dblib, mysql, pgsql, sqlite
pdo_dblib
PDO Driver for FreeTDS/Sybase DB-lib => enabled Flavour => freetds
pdo_mysql
PDO Driver for MySQL => enabled Client API version => mysqlnd
5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd 41fc93cccd5bac2fe7a $
Directive => Local Value => Master Value pdo_mysql.default_socket =>
/run/mysqld/mysqld.sock => /run/mysqld/mysqld.sock
pdo_pgsql
PDO Driver for PostgreSQL => enabled PostgreSQL(libpq) Version =>
9.3.6 Module version => 1.0.2 Revision => $Id: 0e858dd2051ca8c2fd3c781909a0670ab5fecd36 $ pdo_sqlite
PDO Driver for SQLite 3.x => enabled SQLite Library => 3.10.2
Probably, you don't have properly installed PDO_MYSQL. You need to invoke phpinfo() function and see if this module is present. The constant MYSQL_ATTR_SSL_CA comes from PDO library. If php is invoked from CLI then probably it has its own php.ini so you need to enable PDO there as well.
To check if you have enabled PDO in PHP CLI run php -m |grep PDO the command should return PDO string.
To install PDO check the PHP Manual for Installing PDO.
I face this issue as well on all drupal 7 and 8 directory, while drush works fine outside drupal, it doesn't work in Drupal directory. the error says:
Error: Undefined class constant 'MYSQL_ATTR_SSL_CA' in Drush\Sql\Sqlmysql->creds() (line 56 of phar:///usr/local/bin/drush/lib/Drush/Sql/Sqlmysql.php).
Installing php-mysql (or php5-mysql) fix the issue.
I want to connect to my oracle database, but i have a problem with function oci_connect. i have tried to uncomment this:
extension=php_oci8.dll
but, still have an error :
Fatal error: Call to undefined function oci_connect() in C:\xampp\htdocs\testing\db.php on line 71
But, when i check in phpinfo(), oci8 still not loaded and i can not connect to my oracle database. i already restart my apache. How i fix this problem ? Canyou help me?
Thank you..
In Ubuntu 16.04, using PHP 5.6, with 64bit os, try this:
Install the packages:
sudo apt-get install php5.6-dev build-essential php-pear libaio1
Download the latest version of the packages from:
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
Search for these packages, according with the latest version:
oracle-instantclientXX.X-basic-XX.X.X.X.X-X.x86_64.rpm
oracle-instantclientXX.X-devel-XX.X.X.X.X-X.x86_64.rpm
Converting packages:
sudo apt-get install alien
sudo alien oracle-instantclientXX.X-basic-XX.X.X.X.X-X.x86_64.rpm
sudo alien oracle-instantclientXX.X-devel-XX.X.X.X.X-X.x86_64.rpm
Installing:
sudo dpkg -i oracle-instantclientXX.X-basic_XX.X.X.X.X-X_amd64.deb
sudo dpkg -i oracle-instantclientXX.X-devel_XX.X.X.X.X-X_amd64.deb
Installing oci8:
sudo pecl install oci8-2.0.12
*Build process completed successfully
Installing '/usr/lib/php/20131226/oci8.so'
install ok: channel://pecl.php.net/oci8-2.0.12
configuration option "php_ini" is not set to php.ini location
You should add "extension=oci8.so" to php.ini*
Add the extension to php:
sudo gedit /etc/php/5.6/apache2/php.ini
add the extension:
extension=oci8.so
Restart apache:
sudo service apache2 restart
That's it.
In php.ini ensure that you enable the correct OCI extension (11g), like this:
;extension=php_oci8.dll ; Use with Oracle 10gR2 Instant Client
extension=php_oci8_11g.dll ; Use with Oracle 11gR2 Instant Client
As long as you've got Oracle 11gR2 or greater client libraries correctly installed you should now be able to run:
C:\>php --ri oci8
And get the result:
oci8
OCI8 Support => enabled
Version => 1.4.10
Revision => $Id: b0984d94e17f7c099470cd0a9404259f2a59da04 $
Active Persistent Connections => 0
Active Connections => 0
Oracle Run-time Client Library Version => 11.2.0.3.0
Oracle Instant Client Version => 11.2
Temporary Lob support => enabled
Collections support => enabled
Directive => Local Value => Master Value
oci8.max_persistent => -1 => -1
oci8.persistent_timeout => -1 => -1
oci8.ping_interval => 60 => 60
oci8.privileged_connect => Off => Off
oci8.statement_cache_size => 20 => 20
oci8.default_prefetch => 100 => 100
oci8.old_oci_close_semantics => Off => Off
oci8.connection_class => no value => no value
oci8.events => Off => Off
To check your Oracle client is installed correctly (i.e., in your environment PATH variable) you can run:
C:\>where oci*
You should get a result like this:
C:\instantclient_11_2\oci.dll
C:\instantclient_11_2\oci.sym
C:\instantclient_11_2\ocijdbc11.dll
C:\instantclient_11_2\ocijdbc11.sym
C:\instantclient_11_2\ociw32.dll
C:\instantclient_11_2\ociw32.sym
Follow the offcial link for me Oracle
http://www.oracle.com/technetwork/articles/dsl/technote-php-instant-084410.html
Here is what worked with Xammp
1.uncomment extension=php_oci8_11g.dll ; Use with Oracle 11gR2 Instant Client if you are using 11g (in php.ini)
2.add AddHandler fcgid-script .php to httpd.conf
3.Download the FastCGI component mod_fcgid-2.3.6-win32-x86.zip from httpd.apache.org/download.cgi#mod_fcgid
4.Unzip it to the installed Apache 2.2 directory. The C:\xamp\apache\modules directory should now have mod_fcgid.so and mod_fcgid.pdb files.
5.Download the "Instant Client Package - Basic" for Windows from the OTN Instant Client page. Because PHP is 32 bit, use the 32 bit version of Instant Client.
Unzip the Instant Client files to C:\instantclient_11_2
Edit the Windows PATH environment setting and add C:\instantclient_11_2. For example, on Windows XP, follow Start -> Control Panel -> System -> Advanced -> Environment Variables and edit PATH in the System variables list.
Commonly you need to reboot Windows so the new environment is correctly set.
that worked for me all the best
Have a look at RO_engineer's answer of installing x86 files of Oracle insta client rather than x64 version. It resolved my issue, may be that can help you too.
https://stackoverflow.com/a/27177616/289587
Download Instant Client for Microsoft Windows (32-bit)
I am trying to install mongo in php 5.6.0 using MAMP 3.0.
I have correctly downloaded the mongo library and added it to my php.ini.
extension=php_mongo-1.5.7-5.6-vc11.dll
When I run php from the command line, I receive the following (mongo works):
C:\MAMP\bin\php\php5.6.0>php -c ..\..\..\conf\php5.6.0\php.ini -i | findstr /R /C:"mongo"
mongo
mongo.allow_empty_keys => 0 => 0
mongo.chunk_size => 261120 => 261120
mongo.cmd => $ => $
mongo.default_host => localhost => localhost
mongo.default_port => 27017 => 27017
mongo.is_master_interval => 15 => 15
mongo.long_as_object => 0 => 0
mongo.native_long => 0 => 0
mongo.ping_interval => 5 => 5
However, when I start MAMP with errors_on, I receive the following:
PHP startup: Unable to load dynamic library
'C:\MAMP\bin\php\php5.6.0\ext\php_mongo-1.5.7-5.6-vc11.dll' - %1 is not a valid Win32 application.
What am I doing wrong?
Under Windows you have to use the thread safe version. Otherwise the module can't be loaded. You should have a look at the PHP-Version in your case 5.6 of that module and an ts in the filename for your extension.
But i think your problem is that you use a 64bit version. In your package is a file called:
php_mongo-1.5.7-5.6-vc11-x86_64.dll that should work.
https://s3.amazonaws.com/drivers.mongodb.org/php/index.html
I finally resolved this by down-revving php and the mongo driver until I could find one that played well together. I'm using php 5.5.12 with mongo driver php_mongo-1.4.5-5.5-vc11.dll.
I don't think this has anything to do with MAMP per se, it's more about getting apache to play with php and mongo.
After struggling a lot with this problem I finally found how to do it:
find on your enviroment the REAL php.ini location used by the system. To do this create a page with phpinfo() and read it on browser, there you find the location of php.ini configuration, in my enviroment was under C:\Windows
open in admin mode the php.ini file and edit it adding, if not exist, the mongo info about extension: i.e. : extension=php_mongodb.dll ensure you type it right (underscore, "mongodb", etc...); than save all.
in the same file look for the extension_dir, the extension directory used by the current php installation. In my enviroment it was C:\MAMP\bin\php\php7.3.19\ext. Now go there and this is the folder where you have to copy past the RIGHT dll
go here https://pecl.php.net/package/mongodb and find the RIGHT version for your enviroment that means you have to know if you are running on x86 or x64 (look on System Info) and if your config usese Thread Safe or not (run on cmd php -i|findstr "Thread"). In my config it was x64 and TS.....NOW this is THE POINT: under that link you will find a lot of versions i.e. 1.12.0 or 1.7.1 and so on, you have to open the sublink and on bottom of page look if the opened one is compatible with your php version (i.e.: 7.3) BUT you have to do anyway some tries with those dll version, in my case I found that the 1.8.0 was compatible with PHP 7.3 I copied it in the ext folder of point 3) BUT nothing worked, so I needed to find a minor version ALWAYS compatible with my PHP 7.3. So for php 7.3 there were at least 3 dll version (1.8, 1.7, 1.6 and so on...) I had success with dll 1.6....SO MAMP needs to find the right one for your system...as soon as I placed the right files in the ext directory and restarted Apache via MAMP interface, the phpinfo spit out the notice that mongo was recognized!!!
So the trick is just try the right dll for PHP version until it match!
I am trying to make a simple Laravel app.
It seems to be installed correctly but once I run:
localhost/codehero-laravel/public/
(the example code)
it shows the message: "Mcrypt PHP extension required."
It is weird because when I run php -m it appears mcrypt.
Also, if I run "$php --info | grep mcrypt" it appears:
mcrypt
mcrypt support => enabled
mcrypt_filter support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value
I tried everything I've fallen into, so please, can you help me?
Thank you very much!
Depending on your OS, you might have to create a symlink to mcrypt or move the .so file into another folder.
On Ubuntu:
$ sudo php5enmod mcrypt