• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2863
  • Last Modified:

Openssl enabled via web but disabled when using php cli

Hello,

I'm using php 5.4.38 wich was compiled with open ssl (-with-openssl)

Via the web phpinfo() reads :

OpenSSL support 	enabled
OpenSSL Library Version 	OpenSSL 0.9.8o 01 Jun 2010
OpenSSL Header Version 	OpenSSL 0.9.8o 01 Jun 2010 

Open in new window

Using openssl with php cli does not work

php -i | grep ssl
OpenSSL support => disabled (install ext/openssl)

Even if I force php cli to use the web php.ini, I know that when using cli php uses a different php.ini

php -c /usr/local/php54/lib/php.ini -i | grep ssl
OpenSSL support => disabled (install ext/openssl)

I'm stuck there and when i want to download composer for php, the error message reads :
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:
The openssl extension is missing, which means that secure HTTPS transfers are impossible.
If possible you should enable it or recompile php with --with-openssl

Open in new window

Just for the record, here's a copy of my config for compiling php
'./configure' \
'--with-mysql=mysqlnd' \
'--with-mysqli=mysqlnd' \
'--prefix=/usr/local/php54' \
'--with-apxs2=/usr/local/apache2/bin/apxs' \
'--with-gd' \
'--enable-gd-native-ttf' \
'--with-png-dir=/lib' \
'--with-jpeg-dir=/usr/lib' \
'--with-zlib' \
'--enable-ftp' \
'--with-pdo-mysql=mysqlnd' \
'--with-mcrypt' \
'--with-freetype-dir=/usr/lib' \
'--enable-mbstring=all' \
'--with-openssl=/usr' \
'--with-curl=/usr/local/lib' \
'--enable-sockets' \
'--with-gettext=/usr/bin' \
'--enable-soap' \
'--enable-zip' \
'--with-imap=/usr/local/imap-2007f' \
'--with-libdir=lib64' \
'--with-kerberos=/usr' \

Open in new window

0
FFT
Asked:
FFT
  • 4
  • 3
1 Solution
 
gheistCommented:
Are both installations using same php.ini file?
0
 
FFTAuthor Commented:
Hello Gheist,

there is only ONE installation, by default php cli uses a different php.ini as in any php installation (wich is a bit troubling at first)

php --ini
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File:         /usr/local/lib/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

Open in new window


Either by using a symbolic link from /usr/local/lib/php.ini to /usr/local/php54/lib/php.ini or forcing php cli to use a specific config file (php -c /usr/local/php54/lib/php.ini) the result is the same when I try to use httpd conneciton (via curl or readfile) => OpenSSL support => disabled (install ext/openssl)

Inside the php.ini there is no option for openssl apart for the windows library to activate (extension=php_openssl.dll), wich is not relevant in this case (Debian 6)

So i'm really stuck there...
0
 
gheistCommented:
linux php will not activate windows ddl. it must be mod_php.so
0
On-Demand: Securing Your Wi-Fi for Summer Travel

Traveling this summer?Check out our on-demand webinar to learn about the importance of Wi-Fi security and 3 easy measures you can start taking immediately to protect your private data while using public Wi-Fi. Follow us today to learn more!

 
FFTAuthor Commented:
I know that , my current Apache 2 server uses php as an Apache module...
php_sapi_name() returns "apache2handler"

And inside the module line from phpinfo i read "Loaded Modules " : core mod_authn_file mod_authn_default mod_authz_host mod_authz_groupfile mod_authz_user mod_authz_default mod_auth_basic mod_include mod_filter mod_deflate mod_log_config mod_env mod_setenvif mod_version mod_proxy mod_proxy_connect mod_proxy_ftp mod_proxy_http mod_proxy_scgi mod_proxy_ajp mod_proxy_balancer mod_ssl prefork http_core mod_mime mod_status mod_autoindex mod_asis mod_info mod_suexec mod_cgi mod_negotiation mod_dir mod_actions mod_userdir mod_alias mod_rewrite mod_so mod_php5
0
 
gheistCommented:
If you used php shipped with your distribution somebody could eventually help with the issue.
Since you built PHP yourself - either help yourself or move to vendor's PHP.
0
 
FFTAuthor Commented:
Hello,

well the solution was to compile php with the proper directive

--with-openssl=[b]shared[/b] 

Open in new window


instead of

--with-openssl=/usr

Open in new window


This way the module openssl.so is created in the php extensions folder, I had just to activate it via the php.ini  configuration file

extension=openssl.so

Open in new window


Restart Apache and there you go !

# php -i | grep openssl
openssl

Open in new window

0
 
FFTAuthor Commented:
As no one replied I had to search by myself...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

On-Demand: Securing Your Wi-Fi for Summer Travel

Traveling this summer?Check out our on-demand webinar to learn about the importance of Wi-Fi security and 3 easy measures you can start taking immediately to protect your private data while using public Wi-Fi. Follow us today to learn more!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now