Search code examples
phpapachecomposer-phplamppphp-openssl

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

Solution

  • 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.