how to remove unused php versions from ubuntu? - php

Yesterday I tried to install php-gd for php7.2.15 on Ubuntu 18.04 lts. Today when Ubuntu got updated it installed php5.6 php7.0 php7.1 php7.3 beside my php7.2. I think I did something wrong but now I just don't want these versions on my server It's a server holding website and app so can't play with it, php -v now shows:
PHP Warning: PHP Startup: Unable to load dynamic library
'pdo_mysql.so' (tried: /usr/lib/php/20180731/pdo_mysql.so
(/usr/lib/php/20180731/pdo_mysql.so: undefined symbol:
pdo_parse_params), /usr/lib/php/20180731/pdo_mysql.so.so
(/usr/lib/php/20180731/pdo_mysql.so.so: cannot open shared object
file: No such file or directory)) in Unknown on line 0 PHP
7.3.2-3+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Feb 8 2019 15:43:57) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine
v3.3.2, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.2-3+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
But phpinfo file is normal not mentioning anything irregular and everything is functioning like normal, but I'd like to keep my server clean so any advice?

Try to find the pdo_mysql.so file manually using find
Edit your php.ini file so it points to the right location of this file.
Most likely php mysql library got overwritten as a result of installation of multiple versions of php. Also make sure you are editing the right php.ini file.

Related

Mac completely uninstall php that was not installed from brew

I'm running Mac Catalina and want to remove the php version to downgrade to php7.2 possibly use brew from now on.
At the moment I have this.
I don't care much about the error but want I want to achieve is removing completely remove 7.3.11 and then reinstall from brew. I can't find anything about replacing php that is not coming from brew. Please help.
$ php -v
PHP Warning: PHP Startup: Unable to load dynamic library 'php_imap.dll' (tried: /usr/lib/php/extensions/no-debug-non-zts-20180731/php_imap.dll (dlopen(/usr/lib/php/extensions/no-debug-non-zts-20180731/php_imap.dll, 0x0009): dlopen(): file not found: /usr/lib/php/extensions/no-debug-non-zts-20180731/php_imap.dll), /usr/lib/php/extensions/no-debug-non-zts-20180731/php_imap.dll.so (dlopen(/usr/lib/php/extensions/no-debug-non-zts-20180731/php_imap.dll.so, 0x0009): dlopen(): file not found: /usr/lib/php/extensions/no-debug-non-zts-20180731/php_imap.dll.so)) in Unknown on line 0
PHP 7.3.11 (cli) (built: Jun 5 2020 23:50:40) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
I found myself how to do it. I was looking at my user folder while the .profile file was in the root folder. Then I just put this inside:
export PATH="/usr/local/opt/php#7.4/bin:$PATH"
If you want to change the php version see the versions you have in /usr/local/opt/ and change the .profile file. Just reboot after the change.
I hope it will help somebody.

My PHP source code is not executing properly with Apache2 on WSL, always need to restart to apply changes

I am using WSL for PHP development. Since one day, every time I changed my source code and checked on the local address, the change didn't apply until I restart the apache.
I googled about it for a while, nothing came up with this problem.
I reinstalled the PHP and apache2 but nothing changed.
Which file should I look for this problem?
Please could anyone guess what causes this problem?
Below are my PHP version and apache information.
$ php -v
PHP Warning: Module 'exif' already loaded in Unknown on line 0
PHP Warning: Module 'mbstring' already loaded in Unknown on line 0
PHP 7.2.24-0ubuntu0.18.04.6 (cli) (built: May 26 2020 13:09:11) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.24-0ubuntu0.18.04.6, Copyright (c) 1999-2018, by Zend Technologies
$ apache2 -v
Server version: Apache/2.4.29 (Ubuntu)
Server built: 2020-08-12T21:33:25
I've found out the WSL version was 1, so I made it upgrade to WSL2.
The problem solved.

PHP can not load Imagick library - PHP Startup: Unable to load dynamic library

I have High Sierra OS - Version 10.13.6
PHP Version: PHP 7.1.9
when I try to do command php -v always appear error like this:
PHP Startup: Unable to load dynamic library
'/usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/imagick.so'
- dlopen(/usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/imagick.so,
9): Library not loaded:
/usr/local/opt/imagemagick/lib/libMagickWand-7.Q16HDRI.5.dylib
Referenced from:
/usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/imagick.so
Reason: image not found in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library
'/usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/imagick.so'
- dlopen(/usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/imagick.so,
9): Library not loaded:
/usr/local/opt/imagemagick/lib/libMagickWand-7.Q16HDRI.5.dylib
Referenced from:
/usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/imagick.so
Reason: image not found in Unknown on line 0 PHP 7.1.9 (cli) (built:
Sep 14 2017 10:05:35) ( NTS ) Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.9, Copyright (c) 1999-2017, by Zend Technologies
with Xdebug v2.5.3, Copyright (c) 2002-2017, by Derick Rethans
AFAIK, my php.ini failed to load imagick library.
I already install Imagick with brew,
there is a file imagick.so inside folder /usr/local/php5-7.1.9-20170914-100859/lib/php/extensions/no-debug-non-zts-20160303/.
I already search many sources for this issue, I found many similar issues too in StackOverflow, it seems similar to mine but still not fixed my issue.
I can still run PHP script obviously, but cannot do some manipulation image with Imagick.
Try:
sudo pecl uninstall imagick && sudo pecl install imagick
For debugging I suggest you move the dep to a folder easy to debug, such as in /User/<you>/Documents/. You can load it from the absolute path:
extention="/User/<you>/Documents/<project and check if it's a path issue.
I think that you are trying to install the dependency that is older than the current version of PHP, because you are loading the extention from php56 but you are using php71
https://stackoverflow.com/a/50529784/5893008

Setting Correct PATH for Homebrew PHP

I used Homebrew to install PHP versions 5.4 and 5.5 on my system. However, it seems that even after installing and linking to php55 my computer is still trying to run the version initially used by the system.
php --version
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/php_openssl.dll' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/php_openssl.dll, 9): image not found in Unknown on line 0
PHP 5.3.26 (cli) (built: Jul 7 2013 19:05:08)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
I believe Homebrew sets up PHP under '/usr/local/lib' and not '/usr/lib/'.
What do I need to do to correctly have my system use the Homebrew version of PHP?
You have to put /usr/local/bin at the front of your $PATH. In your ~/.bashrc file, add something like
export PATH="$(brew --prefix)/bin:${PATH}"

unable to download dynamic library

I want to install Composer on my Ubuntu 14.04LTS. But during installation I got this:
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
Then in php.ini I remove semicolon';' in line ;extension=php_openssl.dll
After this I've got:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20131226/php_openssl.dll' - /usr/local/lib/php/extensions/no-debug-non-zts-20131226/php_openssl.dll: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 5.6.2 (cli) (built: Oct 29 2014 06:55:23)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
Where can I get this library?
You use php.ini from windows machine. Use default from package manager. For Ubuntu apt-get.

Categories