Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Php composer openssl error

Before asking, i have to say that I have tried every similar question here on stack and elsewhere and failed.

I am unable to use composer because of this error:

requires ext-openssl * -> the requested PHP extension openssl is missing from your system.

I have xampp on ubuntu.

What I have tried:

  • I have uncommented ;extension=php_openssl.dll in php.ini (both cli and normal) - did not work
  • Installed openssl through terminal outside of php - did not work
  • Check in phpinfo() if openssl is loaded and activated

enter image description here

  • and few more like runing composer through php -c /opt/lampp/etc/php.ini composer.phar install where i get error

PHP Warning: PHP Startup: Unable to load dynamic library /usr/include/php5/ext/php_openssl.so - /usr/include/php5/ext/php_openssl.so: cannot open shared object file: No such file or directory in Unknown on line 0

  • I have tried to change PATH in bashrc, no success either

What i have found strange is the location of extensions...

In phpinfo() extension dir is /usr/include/php5/ext/ even though I have tried to specify another dir in php.ini and of course restart apache and still didnt show in phpinfo().

But in php-config command I get that extension dir is /usr/local/lib/php/extensions/no-debug-non-zts-20100525

I'm not sure if i have multiple php on system but I tried to look for php.ini files and only 2 came up.

/etc/php5/cli/php.ini

/opt/lampp/etc/php.ini
like image 200
JTC Avatar asked Mar 02 '16 19:03

JTC


2 Answers

I prefer install LAMP stack vs. xamp: it is simple and easy config package ...

sudo apt-get install apache2
sudo apt-get install curl php5-cli php5 libapache2-mod-php5 php5-openssl
sudo /etc/init.d/apache2 restart
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

To test your installation, run:

  composer

with this command not required changed php.ini and etc.

like image 89
Saeid Avatar answered Oct 19 '22 12:10

Saeid


First of all you have to understand the proper library files system according to OS. In Windows the shared Library files have the extension of DLL and in Linux the shared Library files have the extension of SO.

Wherever you are doing the changes in PHP.ini file is not doing proper. First of all you have to find the correct location of PHP. Since apache service is running it would be easy task to find the location run:

$ httpd -V

Server version: Apache/2.2.17 (Unix)
Server built:   Dec 17 2010 11:58:24
Server's Module Magic Number: 20051115:25
Server loaded:  APR 1.3.12, APR-Util 1.3.9
Compiled using: APR 1.3.12, APR-Util 1.3.9
Architecture:   32-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

The key line in that output is the HTTPD_ROOT. That defines where Apache's ROOT directory is to start, /etc/httpd in my case. Since we have to find the correct location of PHP open SERVER_CONFIG_FILE which would be sub-directory 'conf' as in my case.

Search in the file for env_module which would disclose the correct location of PHP.

<IfModule env_module>
    ....
    SetEnv PHP_PEAR_SYSCONF_DIR "location of PHP"
    SetEnv PHPRC "location of PHP"
    ....
</IfModule env_module>

Now open the PHP.ini file do the required changes

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
; under UNIX:
;
;   extension=msql.so
;
; ... or with a path:
;
;   extension=/path/to/extension/msql.so
;
; If you only provide the name of the extension, PHP will look for it inits
; default extension directory.
;
extension=php_openssl.so

If the problem not resolves then let me know.

like image 27
Vineet1982 Avatar answered Oct 19 '22 13:10

Vineet1982