PHP 7.4 and Ubuntu 18 — PHP Startup: Unable to load dynamic library ‘curl.so’
I’m using the ondrej ppa for PHP and am running Ubuntu 18. Running php -v gives me the following output:
PHP Warning: PHP Startup: Unable to load dynamic library 'curl.so' (tried: /usr/lib/php/20190902/curl.so (/usr/lib/php/20190902/curl.so: symbol curl_mime_addpart version CURL_OPENSSL_4 not defined in file libcurl.so.4 with link time reference), /usr/lib/php/20190902/curl.so.so (/usr/lib/php/20190902/curl.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 PHP 7.4.2 (cli) (built: Jan 23 2020 11:21:30) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.2, Copyright (c), by Zend Technologies
- Tried to update everything ( sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo apt-get install php7.4-curl ). This doesn’t fix the issue.
- Restarted apache despite this being the cli version.
- Double checked where it’s trying to find the library. What’s weird is that /usr/lib/php/20190902/curl.so is a valid path and the file is definitely there.
Running php —ini also shows that the curl extension is loaded:
Configuration File (php.ini) Path: /etc/php/7.4/cli Loaded Configuration File: /etc/php/7.4/cli/php.ini Scan for additional .ini files in: /etc/php/7.4/cli/conf.d Additional .ini files parsed: /etc/php/7.4/cli/conf.d/10-mysqlnd.ini, . more ini files. /etc/php/7.4/cli/conf.d/20-curl.ini, . more ini files.
I’m unsure how to fix this as the file it supposedly can not find is exactly where it says it looked, and everything is up to date.
PHP Startup: Unable to load dynamic library ‘openssl’ in Ubuntu
My real issue with this is that it only occurs sometimes and not always. In one second a request works and in the other, I get a 500 internal error with this message on the same request. This started to occur after I enabled the apache proxy and proxy_wstunnel mods but could also have been an apt-get upgrade or apt-get update . From phpinfo(); :
- Version: PHP Version 7.2.4-1+ubuntu16.04.1+deb.sury.org+1
- OpenSSL support enabled
- OpenSSL Library Version OpenSSL 1.1.0h 27 Mar 2018
- OpenSSL Header Version OpenSSL 1.1.0h 27 Mar 2018
- Openssl default config /usr/lib/ssl/openssl.cnf
If you need futher information feel free to task.
PHP Warning: PHP Startup: Unable to load dynamic library ‘openssl’ (tried: /usr/lib/php/20170718/openssl (/usr/lib/php/20170718/openssl: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/openssl.so (/usr/lib/php/20170718/openssl.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[Fri Apr 20 06:25:01.973125 2018] [mpm_prefork:notice] [pid 2872] AH00163: Apache/2.4.18 (Ubuntu) configured — resuming normal operations
[Fri Apr 20 06:25:01.973154 2018] [core:notice] [pid 2872] AH00094: Command line: ‘/usr/sbin/apache2’
[Fri Apr 20 06:34:04.715749 2018] [php7:error] [pid 3490] [client 5.146.199.236:41654] PHP Fatal error: Uncaught yii\web\HeadersAlreadySentException: Headers already sent in /var/www/html_back/vendor/yiisoft/yii2/web/Response.php on line 414. in /var/www/html_back/vendor/yiisoft/yii2/web/Response.php:366\nStack trace:\n#0 /var/www/html_back/vendor/yiisoft/yii2/web/Response.php(339): yii\web\Response->sendHeaders()\n#1 /var/www/html_back/vendor/yiisoft/yii2/web/ErrorHandler.php(135): yii\web\Response->send()\n#2 /var/www/html_back/vendor/yiisoft/yii2/base/ErrorHandler.php(262): yii\web\ErrorHandler->renderException(Object(yii\base\ErrorException))\n#3 [internal function]: yii\base\ErrorHandler->handleFatalError()\n#4 \n thrown in /var/www/html_back/vendor/yiisoft/yii2/web/Response.php on line 366
[Fri Apr 20 06:34:58.208208 2018] [php7:error] [pid 3486] [client 5.146.199.236:41681] PHP Fatal error: Uncaught yii\web\HeadersAlreadySentException: Headers already sent in /var/www/html_back/vendor/yiisoft/yii2/web/Response.php on line 414. in /var/www/html_back/vendor/yiisoft/yii2/web/Response.php:366\nStack trace:\n#0 /var/www/html_back/vendor/yiisoft/yii2/web/Response.php(339): yii\web\Response->sendHeaders()\n#1 /var/www/html_back/vendor/yiisoft/yii2/web/ErrorHandler.php(135): yii\web\Response->send()\n#2 /var/www/html_back/vendor/yiisoft/yii2/base/ErrorHandler.php(262): yii\web\ErrorHandler->renderException(Object(yii\base\ErrorException))\n#3 [internal function]: yii\base\ErrorHandler->handleFatalError()\n#4 \n thrown in /var/www/html_back/vendor/yiisoft/yii2/web/Response.php on line 366
PHP Warning: PHP Startup: Unable to load dynamic library
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/20160303/php_mbstring.dll’ — /usr/lib/php/20160303/php_mbstring.dll: cannot open shared object file: No such file or directory in Unknown on line 0
sudo apt-get install php-mbstring
sudo phpdismod mbstring # disable mbstring extension sudo phpenmod mbstring # enable mbstring extension again
Thats creating the problem . In one environment its better to install one php, so you may think of removing 5.6, 7.0
@MASIDDIQUI but when i run phpnfo() at that time it shows 5.6 and when run php -v then it shows 7.1.x
1 Answer 1
It seems as if you have multiple versions of PHP installed. It also is likely that all those versions of PHP refer to the very same configuration file ( php.ini ). This configuration file then loads extensions which are available just for some of the PHP installations but not for all.
Furthermore, it seems as if you use a different version of PHP from command line than for your web server.
- If you run php -i from command line, you get information about default PHP CLI (command line interface) installation.
- If you add a file phpinfo.php with somewhere in your htdocs (web server) directory, you see the default PHP version for the web.
Even more strange is that you are trying to load a Windows extension php_mbstring.dll even though you seem to be on Linux.
You should check for each installed PHP which configuration file it uses. The information is part of the output of php -i or phpinfo() . Make sure different versions of PHP use different configuration files.
Check where the DLL file is loaded from via grep -iRn ‘php_mbstring.dll’ /etc . Remove this line or change it to the Linux extension (likely extension=mbstring.so ).
PHP Startup: Unable to load dynamic library (NEW RELIC)
I am running Ubuntu 12.04 with Nginx and the latest PHP. The story goes like this: I tried to install the new relic PHP agent per the instructions for ubuntu:
wget -O - http://download.newrelic.com/548C16BF.gpg | sudo apt-key add - sudo sh -c 'echo "deb http://apt.newrelic.com/debian/ newrelic non-free" > /etc/apt /sources.list.d/newrelic.list' sudo apt-get update sudo apt-get install newrelic-php5 sudo newrelic-install install
And it doesn’t work. After everything the PHP agent simply can’t start. I even whipped up a quick phpinfo.php page to see if the newrelic module was listed and it’s not. So then I googled «New relic .deb» and came across this page: https://docs.newrelic.com/docs/server/server-monitor-installation-ubuntu-and-debian and followed the instructions. The install all goes through but the agent also doesn’t start. I like to keep my servers clean so I decided «OK, since it doesn’t work, until new relic support gets back to me and I can start from fresh I will remove the new relic stuff that was installed». So once again I followed the instructions on that link. The install seemed to work normally. However, if I execute the command » PHP » I get the following error:
root@MYHOSTNAME:/home# php PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212 /newrelic.so' - /usr/lib/php5/20121212/newrelic.so: cannot open shared object file: No such file or directory in Unknown on line 0
I made sure there is no reference to newrelic in my /etc/php/fpm/php.ini file and double checked to see if there was anything in that folder. Nothing. So my question is: how do I get rid of the error? How do I make PHP stop trying to load that newrelic.so module? Is there any reference to it somewhere that I might be missing?