MacOS Mojave and pg_connect with SSL - php

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.

Related

How to use external timezondb for PHP8.1 instead of internal Mac OS

After the updating homebrew, I have an issue with timezonedb. Brew updated "Olson" Timezone Database Version, but it shouldn't be a problem because of timezonedb extension. The problem is: php uses the internal timezone db instead of external one.
Extension installation process:
I installed this extension sudo pecl install timezonedb-2022.5, the version isn't the last, but I need it.
I added it to the .ini file from the conf.d catalog: extension=timezonedb.so
For now if I run the command: php -i | grep -i timezone I received
"Olson" Timezone Database Version => 2022.7
Timezone Database => internal
Default timezone => UTC
date.timezone => no value => no value
timezonedb
Alternative Timezone Database => enabled
Timezone Database Version => 2022.5
It means, that the interpreter sees the installed extension but it is still using the internal database. How can I fix it and use the external one?
php version is 8.1, but I tried with different ones. Php was installed using homebrew + symlink for the particular version (brew install php#8.1 && brew link php#8.1). Other extensions work properly
I fixed it by manually downgrading the minor version PHP to 8.1.7. The guide is below:
Download homebrew formulas (ruby config files) for PHP8.1.7 and icu4c dependency. It's the 72 version for php8.1.15 but must be 70 for php8.1.7 and it can't be installed automatically, because it tries to download the latest version.
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/f03637c77bc52f9fe497e23889db4563eb85299b/Formula/php.rb
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/f03637c77bc52f9fe497e23889db4563eb85299b/Formula/icu4c.rb
Reinstall icu4c using the command brew reinstall icu4c.rb. Check the Cellar: /usr/local/Cellar/icu4c/. You should have the 70.1 catalog.
Remove an old symlink rm /usr/local/opt/icu4c
Create a new one: ln -s /usr/local/Cellar/icu4c/70.1 /usr/local/opt/icu4c
Patch the ruby config for PHP. Remove depends_on "icu4c" to avoid downloading the last version of icu4c, save it
Reinstall PHP brew reinstall php.rb. If it's not default, symlink it.

Laravel 4.2 on PHP 7.2 with Mcrypt enabled still shows 'Mcrypt PHP extension required.' on browser

I am trying to run a Laravel application (4.2.22) locally with Laravel Homestead 8 that runs on php 7.2 with mcrypt.
I installed mcrypt and enabled it on both php.ini cli and apache2... I have tried everything but my browser still shows "Mcrypt PHP extension required." when I run the application... I was able to even install dependencies (composer install) without showing "mcrypt required"
php -i | grep "mcrypt" shows:
mcrypt
mcrypt support => enabled
mcrypt_filter support => enabled
php -m shows mcrypt
Is this something that might have to do with Laravel, Composer or some caching?
Checked phpinfo() and noticed the server was using etc/php/7.2/fpm/php.ini I added extension=mcrypt.so to the php.ini file and now it is working on the browser.

PHP - PDO Mysql not found! php_mysql.so exists, but phpinfo only shows sqlite

I installed different php versions on my Debian server for some reasons (Php 5.3.10, 5.4.41, 5.5.25, 5.6.9 and 7.0.17). I installed them from source.
I'm trying to get the mysql php pdo to work with php 5.3.10.
The active version on Debian is 5.4.41. and php5-mysql is installed by
sudo apt-get install php5-mysql
When I check php info in the console or by phpinfo(); for php 5.4.41 the result is:
~$ php --info | grep pdo
Additional .ini files parsed => /etc/php5/cli/conf.d/10-pdo.ini,
/etc/php5/cli/conf.d/20-pdo_mysql.ini
pdo_mysql
pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock
But result of phpinfo() in another vHost that works with php 5.3.10 is:
and
and
Even I uncomment *.so files in php.ini
extension=mysql.so
extension=pdo.so
But no pdo_mysql.so being loaded!
Extra info:
OS: Debian 7.8
Server version: Apache/2.2.22 (Debian)
Any ideas?
Thanks!

can not load oci8 -> Fatal error: Call to undefined function oci_connect()

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)

Mcrypt not detected with Laravel installation

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

Categories