php GD library error in ubuntu - php

I am using ubuntu 11.04 and when I am opening terminal and typing php -a it is showing some error like this
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/gd.so' - /usr/lib/php5/20090626/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
I think there is some problem with GD library.Is there any option to solve it?

Yeah. Just try:
sudo apt-get install php5-gd
You probably will have to remove the offending line in your php.ini, either in php.ini or in
/etc/php5/conf.d/gd.ini maybe.

Probably something like
sudo apt-get install php-gd
should do it, if not try
apt-cache search php | grep gd

For me the solution was:
locate --regex /mcrypt[.]so\$ /gd[.]so\$ /suhosin[.]so\$ /pdo_mysql.so\$ /pdo[.]so /mysqli[.]so\$ '/php5/.*/mysql[.]so$'
Which returned the location of all the libraries that my php5 install was having trouble finding:
/usr/lib/php5/20090626+lfs/gd.so
/usr/lib/php5/20090626+lfs/mcrypt.so
/usr/lib/php5/20090626+lfs/mysql.so
/usr/lib/php5/20090626+lfs/mysqli.so
/usr/lib/php5/20090626+lfs/pdo.so
/usr/lib/php5/20090626+lfs/pdo_mysql.so
I was a little worried that these look they might be old versions, but I used their paths anyway. Stefgosselin identified the location of the ini files, /etc/php5/conf.d/. I modified them all. The command below will modify all of the *.ini files there, so make sure all of yours really need modifying. Obviously you need to use the target path you discovered with the locate command in place of mine, /usr/lib/php5/20090626+lfs/:
sudo sed -ri -e "s|^(extension=)(\w{2,10}[.]so)$|\1/usr/lib/php5/20090626+lfs/\2|g" /etc/php5/conf.d/*.ini
Before finding this solution I tried several apt-get purge and apt-get reinstall commands without luck. I'm not sure, but my problem may have originated with installation of zend from source or phpmyadmin with aptitude. It never caused any php errors, just the annoying warning you mentioned. Finally php5 can launch without errors:
php5 --version
gives ...
PHP 5.3.5-1ubuntu7.2 with Suhosin-Patch (cli) (built: May 2 2011 23:18:30) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH

sudo apt install php-gd will work but the thing is it will download the plugin for the latest PHP version.
If your PHP version is not the latest, then you can add version in it:
# PHP 7.1
sudo apt install php7.1-gd
# PHP 7.2:
sudo apt install php7.2-gd
# PHP 7.3
sudo apt install php7.3-gd
# PHP 7.4 (latest)
sudo apt install php-gd

Related

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
Basically, I can't run any composer commands because a lot of libraries depend on curl, and apparently it isn't being found. I've done the following:
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.
For anyone with this issue, the answer is here.
Basically, the libcurl that was installed on my Ubuntu machine clashed with the official one that Ubuntu has? Weirdly it was only affecting php7.3 and 7.4 and not 7.2. Anyways, I renamed the libcurl module like so:
mv /usr/local/lib/libcurl.so.4.4.0 /usr/local/lib/libcurl.so.4.4.0.backup
And by running php -m, I could verify that the cURL module was now enabled.
I found that if I did:
apt search | more
(the pipe is for long lists)
that I could find the php package name that I needed.
For example:
apt search curl
told me that the name of the package for my php version is 'php7.2-curl'
So, all I had to do was sudo apt install php7.2 curl.
I repeated this (some names require a little googling, and/or some apt search creativity.
I solved it by doing this:
Uninstall curl:
apt remove php7.4-curl
New install:
apt install php7.4-curl
I have now all right.
After trying to run composer update things were failing because the deps where from php -v 7 while I was using 8.
composer install --ignore-platform-reqs
worked for me

How to enable PHP Intl extension on macOS Mojave?

I'm trying to install Magento (2.3.0) on macOS Mojave. Magento shows PHP Extension intl. is missing.
I tried the below to resolve:
Made a copy of php.ini using cp /etc/php.ini.default php.ini
Removed ";" before extension=php_intl.dll
Restart Apache sudo apachectl restart
But the above did not resolve.
On checking php -v, i'm seeing the below error:
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20160303/php_intl.dll' -
dlopen(/usr/lib/php/extensions/no-debug-non-zts-20160303/php_intl.dll,
0x0009): dlopen(): file not found: /usr/lib/php/extensions/no-debug-
non-zts-20160303/php_intl.dll in Unknown on line 0
PHP 7.1.19 (cli) (built: Aug 17 2018 20:10:18) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
There are only 2 files under /usr/lib/php/extensions/no-debug-non-zts-20160303 namely opache.so and xdebug.so
How can i install or enable "PHP Extension intl" on my macOS Mojave?
Here's a solution that worked for me:
Find all PHP versions installed brew list | grep php
Remove all versions of PHP brew remove --ignore-dependencies --force php70 php71 php72 (based on what you see above)
Install PHP brew install php72 (i chose 7.2, 7.3 is not supported yet by several vendors)
Run the command which php should show you the path to the installed PHP. Copy the path.
Update your bash_profile vi ~/.bash_profile and add this line to the file:
export PATH=/usr/local/php5/bin:$PATH
Save and run this source ~/.bash_profile
Check if PHP Intl Extension is installed using php -m | grep intl. If the installation went well, we will see intl listed. If not the extension is not installed.
I think from PHP 7 (not sure of the version), the extensions are available by default and we need not enable them in php.ini file explicitly.
If you installed Homebrew's php, linking it to a directory in your path will fix the issue.
brew link --force php#7.3
I had the same issue and that fixed it.
Here is a link where I got a detailed answer from
Got help from the link and able to compile https://donatstudios.com/Install-PHP-Mcrypt-Extension-in-OS-X
Next we will download the PHP source. Verify the exact version of PHP you are running. This can be retrieved as follows. The version is highlighted.
$ php --version
PHP 7.1.19 (cli) (built: Aug 17 2018 18:03:17) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Now we move into a working directory and download the source making sure to update the following for the version from above.
$ cd /tmp
$ curl -L http://php.net/get/php-{{php-version}}.tar.bz2/from/this/mirror > php.tar.bz2
$ open php.tar.bz2
Now we will compile and test the extension.
$ cd php-{{php-version}}/ext/{{extension}}
$ phpize
$ ./configure
$ make
$ make test
$ sudo make install
If all that goes well finally we'll need to add the following to our php.ini - I usually add at it at the end of the file.
extension = {{extension}}
.so
You can verify your installation with the following:
$ php --info | grep {{extension}}\\.
Lastly, depending on your setup now you may want to restart apache.
$ sudo apachectl restart

failed to install php-integrator-base package in atom editor

I am new on this editor and I would like to try it for php project.
I am trying to configure this package php-integrator-base in my atom ide, but I have this error:
The socket connection with the PHP server could not be established.
This means the PHP server could not be spawned. This is most likely an
issue with your setup, such as your PHP binary not being found, an
extension missing on your system, ...
This is my setup for this package:
This my php verion on my ubuntu distrib:
Anyone else have the same issue with this package ? Where am I wrong ?
EDIT
Since I have make the update of the package today I always have the same error but another one occured.
Indeed, an error message appears to notice that:
Core installed failed
When I start the atom editor I have this message too:
If you are on Unix system then go to :
cd $HOME/.atom/packages/php-integrator-base/core/
then you should have a directory with num version as name like 2.X.X. So :
cd 2.1.0 and ../composer.phar install
I am relevantly new to this IDE as well and had errors with installation of php-integrator-base. I am using Windows and it turned out that it was an issue with my environmental path. Try the following steps:
Add your Git binary path to your environmental path
Enable sqlite on your php.ini file by adding these: extension=php_sqlite3.dll and extension=php_pdo_sqlite.dll
If above steps do not work, try posting an issue at their GitHub repo.
There is a better solution, which solves this "identified" issue and others only visible when running Atom in --dev mode.
Sadly nobody ever pointed to the fact (or noticed) this issue is caused by packages differences in between PHP 7.0 and PHP 7.1. For some reason, for PHP 7.1 some packages still reference items related to PHP5.6, while some other packages are expecting everything to be PHP 7.x related.
The solution is to upgrade the PHP 7.0x to PHP 7.1.
In Ubuntu environments you can do that by running these commands:
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt remove php7.0 (optional, only if you want to uninstall PHP7.0)
sudo apt install php7.1
Simply restart Apache by running:
sudo service apache2 restart
Then check your PHP version to confirm it has been upgraded:
php -v
You should get an output like this:
PHP 7.1.8-2+ubuntu16.04.1+deb.sury.org+4 (cli) (built: Aug 4 2017 13:04:12) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.8-2+ubuntu16.04.1+deb.sury.org+4, Copyright
(c) 1999-2017, by Zend Technologies
You may have to re-enable some extensions after upgrading to PHP 7.1. Atom may complain about these in specific (mbString, SQLite and DOM). Simply run these commands to install/activate them:
sudo apt install php7.1-mbstring
sudo apt install php7.1-sqlite
sudo apt install php7.1-xml
Don't forget to reactivate your old extensions as well (if any). For PHP 7.1 in most cases it is the same "command" just changing "php7" (or "php") to "php7.1".
Once you are done with PHP, navigate to Atom's PHP Integrator folder and check if the folder "3.0.0" exist:
.atom/packages/php-integrator-base/core/3.0.0/
If it doesn't exist go to https://gitlab.com/php-integrator/core/tree/3.0.0, download it and extract the contents of the compressed file in the 3.0.0 folder (you may have to create it):
Then, from inside .atom/packages/php-integrator-base/core/ you run:
composer install
Now, finally, Composer will be able to find the right packages and install all required dependencies.
Simply say "good bye" to the PHP Integrator errors that have been haunting you lately and enjoy your Atom, once again fully functional as it should be.
I hope it helps some fellow friends stop wasting time with lots of proposed solutions that exist online which in reality won't fix the real core of the problem. ;)
Following #Rei suggestion, I make an issue on theri github repo here.
To solve my problem, I follow step by step a manual installation of the package and then use composer inside the package itself to install the core folder.
If ./composer.phar install fails with a "missing sqlite extension", install php-sqlite extension:
sudo apt-get install php-sqlite3

php cgi error in PhpStorm when php-cgi is installed

I am having a problem with PhpStorm (10.0.3) on OS X El Capitan‎ throwing a php-cgi not found error on PHP 7 cgi/fastcgi. I tried the solutions offered in "How do I install php-cgi? I tried MacPort, Package and everything else but none works", but these did not work. I've consulted this: http://blog.jetbrains.com/phpstorm/2013/09/built-in-webserver-in-phpstorm/ but it is not helpful. I also tried a cgi install of PHP 5.6 but this has the same problem as PHP 7.
I have installed PHP70-cgi using macport and verified the install is cgi-fcgi:
$ php-cgi70 -v
PHP 7.0.2 (cgi-fcgi) (built: Jan 19 2016 16:48:28)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
When I try to use php-cgi70 from within PhpStorm it appears to incorrectly default to CLI:
PHP version: 7.0.2
PHP CLI: /opt/local/bin/php-cgi70 PHP CGI: Not Installed (php-cgi sapi is necessary to use built-in web server)
Loaded Configuration File: /opt/local/etc/php70/php.ini
I've also tried the macport install of php-fpm70, but this is not recognized by PhpStorm.
Does anyone have any ideas on resolving this? Thanks in advance.
PhpStorm can't find the PHP CGI binary. Do this on your shell to fix:
cd /opt/local/bin
sudo ln -s php-cgi70 php-cgi
sudo apt-get install php-xdebug
Another way for macOS is to install PHP all together with simple cURL:
curl -s https://php-osx.liip.ch/install.sh | bash -s 7.2
OR install Homebrew and then PHP with CGI (better practice):
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install php72 --with-cgi --with-debug --with-libmysql
And link it in PhpStorm:
Image: PhpStorm: PHP Config
For more info about Homebrew, visit documentation here.

PHP installation conflicts on Centos6

I'm new to server and linux and I ran into some problems. I'm trying to update my PHP by looking for linux commands through the net. Some commands ran perfectly but some not.
I tried using this command to install php-gd since I have this error message 'Required GD library is missing'. So, I tried to run this below:
yum install php-gd
However, it give me this error message below:
php56w-common conflicts with php-common-5.3.3-46.el6_6.x86_64
Here are some info on my server:
[root#uat ~]# rpm -ql php
package php is not installed
[root#uat ~]# rpm -qa php\*
php56w-pdo-5.6.11-1.w6.x86_64
php56w-5.6.11-1.w6.x86_64
php56w-cli-5.6.11-1.w6.x86_64
php56w-common-5.6.11-1.w6.x86_64
php56w-mysql-5.6.11-1.w6.x86_64
[root#uat ~]# rpm -Va php\*
S.5....T. c /etc/php.ini
[root#uat ~]# which php
/usr/bin/php
[root#uat ~]# php -v
PHP 5.6.11 (cli) (built: Jul 10 2015 22:43:20)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
Do you know what have I done wrong upgrading my php? Should I remove all php files on my server and reinstall? How?
Solved it by removing all php using "yum remove php php-common"
and modified the filename "remi.repo" under the folder /etc/yum.repos.d like below:
[remi-php56]
name=Remi's PHP 5.6 RPM repository for Enterprise Linux 6 - $basearch
#baseurl=http://rpms.remirepo.net/enterprise/6/php56/$basearch/
mirrorlist=http://rpms.remirepo.net/enterprise/6/php56/mirror
# WARNING: If you enable this repository, you must also enable "remi"
enabled=1
gpgcheck=1
making sure that php56 is enabled=1.
You should run:
yum install php56w-gd
So when install php-extension have error:
*-common conflicts with php-common-5.3.3-46.el6_6.x86_64
Just type *-extension
Example:
yum install php-fpm have error
Error: php56u-common conflicts with php-common-5.3.3-46.el6_7.1.x86_64
then you should run
yum install php56u-fpm
The reason of this error is you install a php version don't match the system repo version. So yum get a version of the system repo, but this don't compatible with the php version you have installed. When you specific the php version, yum get the right version, so happy!
Go to /etc/yum.repos.d.
Remove the extra repository that you can see in your complete error message.
Nima
If you are using Centos 6.7 and have php 5.6 installed, the following command worked for me:
sudo yum install php56w-pecl-xdebug.x86_64 (I was installing xdebug, not GD)
I found this by running yum search php56

Categories