PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_openssl.dll'

15,013

Solution 1

If you are using mysql ssl do not use localhost, use server IP address for database host.

Solution 2

Dynamic link libraries (DLLs) are a Windows-specific technology and don't work on Ubuntu. Because PHP can be run on different operating systems, its configuration files contain examples for how to configure it on different operating systems:

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename.extension
;
; For example, on Windows:
;
;   extension=msql.dll
;
; ... or under UNIX:
;
;   extension=msql.so
;
; ... or with a path:
;
;   extension=/path/to/extension/msql.so

Normally, the Linux build of PHP already comes with SSL support built in, in contrast to the Windows build, where you need the DLL you mentioned. But you seem to use a third-party build of PHP 7 (maybe a from PPA?), because Ubuntu 14.04 comes with PHP 5 by default. So this third-party build might handle SSL differently.

Share:
15,013
iWizard
Author by

iWizard

Somewhere in code...

Updated on September 18, 2022

Comments

  • iWizard
    iWizard over 1 year

    I have ubuntu 14.04., php 7 and nginx.

    I want to use mysql ssl so I have enabled by removing ";" in front of extension=php_openssl.dll in

    /etc/php/7.0/fpm/php.ini 
    /etc/php/7.0/cli/php.ini
    

    Restarted php and nginx services. Now I'm getting error:

    PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_openssl.dll' - /usr/lib/php/20151012/php_openssl.dll: cannot open shared object file: No such file or directory in Unknown on line 0
    

    File "/usr/lib/php/20151012/php_openssl.dll" really does not exist.

    Php script with which I'm trying to connect on mysql ssl:

    $con=mysqli_init();
    if (!$con){
        die("mysqli_init failed");
    }
    
    mysqli_ssl_set($con, "/var/www/certs/client-key.pem","/var/www/certs/client-cert.pem","/var/www/certs/ca-cert.pem",NULL, null);
    
    if (!mysqli_real_connect(
        $con,"localhost","user", 'password',"db", 3306)){
        die("Connect Error: " . mysqli_connect_error());
    }
    mysqli_close($con);
    

    Permissions on all cert files are ok, tried wit 644, 664, 777.

    Tried to execute script over browser and over console.

    Where I can find missing package?

    Thank you

    UPDATE 1: If I comment back "extension=php_openssl.dll" in php.ini files then I get another error:

    PHP Warning:  mysqli_real_connect(): this stream does not support SSL/crypto in /var/www/tmp.php on line 70
    

    phpinfo: enter image description here

    • Sledge Hammer
      Sledge Hammer almost 8 years
      OpenSSL should be enabled by default in the Linux version of PHP (as long as you have OpenSSL installed on your system), so in theory all you need to do is bring back the comment to that line. You can make sure that you have OpenSSL enabled by looking at the output of phpinfo();As for the other stuff - try checking the php, mysql and nginx error logs for any more info on why you can't connect.
    • iWizard
      iWizard almost 8 years
      @SledgeHammer - updated my answer. If I do that then I get another error
    • iWizard
      iWizard almost 8 years
      @SledgeHammer - found solution. If you are using mysql ssl do not use localhost, use server IP address
  • iWizard
    iWizard almost 8 years
    Cannot find packege
  • iWizard
    iWizard almost 8 years
    Found solution. If you are using mysql ssl do not use localhost, use server IP address