Problem:
I have a Docker compose with an nginx service and a PHP service.
When I try to open a page of my dev project, I encounter this error:
Fatal error: Call to undefined function bindtextdomain() in /usr/share/nginx/html/some_project/some_path/Bootstrap.php on line 16
I saw that is a problem of a missing dependency: php-gettext.
My configuration:
In my Dockerfile, I try to install it:
FROM php:5.6.30-fpm
MAINTAINER DarckCrystale "xxx#xxx.xx"
# Here I try to install the php-gettext extension
# but it does not work
RUN apt-get update && apt-get install -y php-gettext gettext
# Setup PHP configuration
ADD php.ini /usr/local/etc/php/conf.d/php.ini
In my php.ini, I load it:
extension=gettext.so
Other information:
When I run in my container
php -i | grep extension_dir
I have this message displayed:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20131226/gettext.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20131226/gettext.so: cannot open shared object file: No such file or directory in Unknown on line 0
What it seems to be to me:
I think
RUN apt-get update && apt-get install -y php-gettext gettext
does not install the php-gettext extension. I don't know why. I think this is a PHP Dockerized specific problem.
So, after struggle, I finally found how to install this extension in the PHP container!
How to solve this problem?
Use docker-php-ext-install instead of apt-get install in the Dockerfile:
FROM php:5.6.30-fpm
MAINTAINER DarckCrystale "xxx#xxx.xx"
# Here I install the php-gettext extension
# and it works! :D
RUN docker-php-ext-install gettext
# Setup PHP configuration
ADD php.ini /usr/local/etc/php/conf.d/php.ini
What is the problem?
PHP container have a specific way to install PHP extensions:
How to install more PHP extensions
We provide the helper scripts docker-php-ext-configure, docker-php-ext-install, and docker-php-ext-enable to more easily install PHP extensions.
So php-gettext extension installation seems to work only using provided scripts.
Related
I know there has been a lot of question asked regarding installing imagick to Php7+, unfortunately all the answer doesn't solve my issue.
I just update to php7.4, so I follow the previous setting from 7.3, 7.2 to enabled imagick,
basically:
echo extension=imagick.so > /etc/php/7.4/mods-available/imagick.ini
then soft link to "fpm" and "cli" directory:
ln -s /etc/php/7.4/mods-available/imagick.ini /etc/php/7.4/fpm/conf.d/20-imagick.ini
ln -s /etc/php/7.4/mods-available/imagick.ini /etc/php/7.4/cli/conf.d/20-imagick.ini
reloaded the php7.4-fpm, but imagick still failed to load
verify with php -i | grep imagick but got an error of:
PHP Warning: PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/lib/php/20190902/imagick.so (/usr/lib/php/20190902/imagick.so: cannot open shared object file: No such file or directory), /us
r/lib/php/20190902/imagick.so.so (/usr/lib/php/20190902/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Note:
- I have tried to purge php-imagick and reinstall it, but doesn't work.
I solved it on my raspi this way (based on the instructions here: How to Install PHP imagick extension):
sudo apt install php7.4-dev (if not already installed)
check your pecl Version (must match with 7.4): pecl version
make sure that sed is executable from /bin/sed (the pecl install needs it to be there, I had to symlink it from /usr/bin/sed)
sudo apt install libmagickwand-dev
sudo pecl install imagick
Then you can carry on with the steps you already made:
sudo echo extension=imagick.so > /etc/php/7.4/mods-available/imagick.ini
sudo ln -s /etc/php/7.4/mods-available/imagick.ini /etc/php/7.4/fpm/conf.d/20-imagick.ini
sudo ln -s /etc/php/7.4/mods-available/imagick.ini /etc/php/7.4/cli/conf.d/20-imagick.ini
After that, restart your services (php7.4-fpm, apache, nginx, ...).
Hope this helps!
Also got this error and took a solid 2 hours to solve:
PHP Warning: PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/lib/php/20190902/imagick.so (/usr/lib/php/20190902/imagick.so: cannot open shared object file: No such file or directory), /phpusr/lib/php/20190902/imagick.so.so (/usr/lib/php/20190902/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Even though php -i showed that my configured php version was 7.4 and that imagick extension was installed, I could not get rid of this warning.
So after running alot of commands and reading on the net, I figured the most obvious thing to do is check the given directory /usr/lib/php/20190902/. So annoyingly even after installing imagick with
sudo apt install php-imagick
it was not installed in that directory, but was for php8.0. This command
apt search imagick
had already showed this,
php7.4-imagick/focal,now 3.5.1-1+ubuntu20.04.1+deb.sury.org+1 amd64
Provides a wrapper to the ImageMagick library
php8.0-imagick/focal,now 3.5.1-1+ubuntu20.04.1+deb.sury.org+1 amd64 [installed,automatic]
Provides a wrapper to the ImageMagick library
but I did not grasp [installed] being missing.
Solution in the end was to install my configured php version specific imagick with
sudo apt install php7.4-imagick
I checked if installed with php -m | grep imagick and double checked with ll /usr/lib/php/20190902 and ran command sudo systemctl restart apache2 before all was well again.
To install Imagick run bellow command:
sudo apt-get install php-imagick
For specific PHP version (in my case 7.1):
sudo apt-get install php7.1-imagick
Then restart apache:
sudo service apache2 restart
To check if the extension has been installed:
php -m | grep imagick
I am trying to update laravel using composer update on ubuntu 06.04 but everytime i run composer update this warning always comes up.
PHP Warning: PHP Startup: Unable to load dynamic library 'mcrypt.so' (tried: /usr/lib/php/20170718/mcrypt.so (/usr/lib/php/20170718/mcrypt.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/mcrypt.so.so (/usr/lib/php/20170718/mcrypt.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Does anyone knows how to deal it?
I am using php7.2
I faced similar issue when I installed Php7.2 on Ubuntu 18. Though I had installed mcrypt using PECL still I get the error mentioned in the question.
I did following to fix it
sudo apt-get install php-pear php7.2-dev
then uninstalled
pecl uninstall mcrypt
Now reinstall mcrypt
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install libmcrypt-dev
sudo pecl install mcrypt-1.0.1
When you are shown the prompt
libmcrypt prefix? [autodetect] :
Press [Enter] to autodetect.
After success installing mcrypt using pecl, you should add mcrypt.so extension to php.ini.
The output will look like this:
...
Build process completed successfully
Installing '/usr/lib/php/20170718/mcrypt.so' ----> this is our path to mcrypt extension lib
install ok: channel://pecl.php.net/mcrypt-1.0.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=mcrypt.so" to php.ini
Now restart Apache
sudo service apache2 restart
Grab installing path and add to cli and apache2 php.ini configuration.
sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/cli/conf.d/mcrypt.ini"
sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/apache2/conf.d/mcrypt.ini"
First, open up a terminal window and install the necessary dependencies with the commands:
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install php7.2-dev
sudo apt-get -y install libmcrypt-dev
Once the dependencies have been installed, you can install mcrypt with the command:
sudo pecl install mcrypt-1.0.1
And there you go. Mcrypt is now installed. Go back to the process of installing whatever server software that depends upon this extension and you should be good to go.
For (>= PHP 7.3) you can use the following command:
sudo pecl install mcrypt-1.0.2
I faced this problem when I upgraded my PHP to 7.3
I found mcrypt.so was still present in /etc/php/7.3 that should not be as it is deprecated in php 7.3 so just deleting mcrypt.so from /etc/php/7.3 solved issue.
I used following commands:
cd /etc/php/7.3
sudo rm -rf mcrypt.so
sudo service apache2 restart
İts is worked for me.
export LC_ALL="C"
export LANG="C
sudo pecl install mcrypt-1.0.1
Also, if you're using php 7.2 & are getting this error and you know do not want/need mcrypt, but do not know how to exclude it.... You need edit your php.ini file and either comment this out by using a semi-colon in front of it:
; extension=mcrypt.so
or just delete that line entirely.
I tried to install the mongodb driver for PHP on Amazon Linux.
While running sudo pecl install mongo, I get the error message:
fatal error: openssl/evp.h: No such file or directory
#include <openssl/evp.h>
^
compilation terminated.
make: *** [io_stream.lo] Error 1
ERROR: `make' failed
PEAR Version: 1.9.5
PHP Version: 5.3.29
I installed gcc which helped me progress further with the install till this error.
The best Guide I was able to find was here:
http://jonathanhui.com/install-mongodb-amazon-linux
PHP's guide: http://php.net/manual/en/mongo.installation.php
evp is high-level cryptographic functions.
Try to install development libraries:
Ubuntu:
sudo apt-get install libssl-dev
CentOS:
yum install openssl-devel
The right package to install is not libssl-dev but
sudo apt-get install pkg-config
and now you can execute
sudo pecl install mongodb
Don't forget to add extension=mongodb.so to your php.ini file.
To know which php.ini file is loaded you can create and simple php file on vps
<?php
php_info()
?>
Example directory php.ini in phpinfo()
I'm trying a simple web service example and I get this error even though I uncommented extension=php_soap.dll in the php.ini file:
Fatal error: Class 'SoapClient' not found in C:\Program Files (x86)\EasyPHP-5.3.9\www\server.php on line 2
Diagnose
Look up the following inside your script file
phpinfo();
If you can't find Soap Client set to enabled like so:
Fix
Do the following:
Locate php.ini in your apache bin folder, I.e Apache/bin/php.ini
Remove the ; from the beginning of extension=php_soap.dll
Restart your Apache server
Look up your phpinfo(); again and check if you see a similar picture to the one above
If you do, problem solved!
On the other hand if this doesn't solve your issue, you may want to check the requirements for SOAP here. Also in the comment section you can find good advice on connecting to https.
To install SOAP in PHP-7 run following in your Ubuntu terminal:
sudo apt-get install php7.0-soap
To install SOAP in PHP-7.1 run following in your Ubuntu terminal:
sudo apt-get install php7.1-soap
To install SOAP in PHP-7.2 run following in your Ubuntu terminal:
sudo apt-get install php7.2-soap
To install SOAP in PHP-7.3 run following in your Ubuntu terminal:
sudo apt-get install php7.3-soap
For AWS (RHEL):
sudo yum install php56-soap
(56 here is 5.6 PHP version - put your version here).
To install SOAP in PHP5.6 run following in your Ubuntu 14.04 terminal:
sudo apt-get install php5.6-soap
service php5.6-fpm restart
service apache2 restart
See if SOAP was enabled:
php -m
(You should see SOAP between returned text.)
I had to run
php-config --configure-options --enable-soap
as root and restart apache.
That worked! Now my phpinfo() call shows the SOAP section.
I solved this issue on PHP 7.0.22-0ubuntu0.16.04.1 nginx
sudo apt-get install php7.0-soap
sudo systemctl restart php7.0-fpm
sudo systemctl restart nginx
I couln't find the SOAP section in phpinfo() so I had to install it.
For information the SOAP extension requires the libxml PHP extension. This means that passing in --enable-libxml is also required according to http://php.net/manual/en/soap.requirements.php
From WHM panel
Software » Module Installers » PHP Extensions & Applications Package
Install SOAP 0.13.0
WARNING: "pear/HTTP_Request" is deprecated in favor of "pear/HTTP_Request2"
install ok: channel://pear.php.net/SOAP-0.13.0
Install HTTP_Request2 (optional)
install ok: channel://pear.php.net/HTTP_Request2
Restart Services » HTTP Server (Apache)
From shell command
1.pear install SOAP
2.reboot
For XAMPP users, open php.ini file located in C:/xampp/php and remove the ; from the beginning of extension=soap. Then restart Apache and that's it!
For Docker* add this line:
RUN apt-get update && \
apt-get install -y libxml2-dev && \
docker-php-ext-install soap
*: For debian based images, ie. won't work for alpine variants.
For PHP 7.4 & Docker
add this line in Dockerfile:
RUN apt-get update && apt-get install -y \
libxml2-dev \
RUN docker-php-ext-install soap
Rebuild the image and restart ;)
You have to inherit nusoap.php class and put it in your project directory, you can download it from the Internet.
Use this code:
require_once('nusoap.php');
On Centos 7.8 and PHP 7.3
yum install php-soap
service httpd restart
For PHP 8:
sudo apt update
sudo apt-get install php8.0-soap
In my case, the Symfony cache was causing the problem,
after running composer install the problem was gone.
I had a similar problem. It was due to the scope and solved by replacing new SoapClient by new \SoapClient.
I am trying to install pspell for PHP 5 in Ubuntu. I have installed the aspell library which is required to run pspell as shown here
I am not sure if there are any settings I need to change, etc.
When I try to execute the below mentioned line of code
$pspell_link = pspell_new("en");
I get an error
Fatal error: Call to undefined function pspell_new()
Any idea on what could be wrong ?
Any help greatly appreciated.
just do
sudo apt-get install libpspell-dev
sudo apt-get install php5-pspell
sudo apt-get install aspell-en
then restart your apache2 server with the following command
sudo service apache2 restart
it will be added automatically to your php.ini
you can try this example
For those using PHP 7.2 / Ubuntu 18.10, here is what I did to get PSPELL working:
sudo apt-get install php5-pspell
sudo apt-get install php-pspell
sudo apt-get install aspell-en
sudo apt-get install aspell-fr
sudo apt-get install aspell-de
sudo apt-get install aspell-es
sudo service apache2 restart
I use multiple languages, so included some of them in the example above. I believe EN is included by default.
"I have installed the aspell library which is required to run pspell as shown here"
that's if you compile your own PHP - did you recompile with pspell?
Note that this package just provides the API and data, you are getting an error becuase your PHP doesn't know how to interface with it.
If you're not into building your own code, the PHP extension is available as a package:
(NB this is JUST the PHP side of the service)
http://packages.ubuntu.com/source/dapper/php-pspell
C.
Have you configured php.ini to load the extension?