How to install php yaml on CentOs? - php

On the start I was getting this error:
Call to undefined function yaml_parse_file()
I have tried everything what I have found over google:
yum install libyaml
yum install yaml
yum install perl-yaml
and etc.
Now I'm getting:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/extensions/no-debug-non-zts-20100525/yaml.so' - /usr/lib64/extensions/no-debug-non-zts-20100525/yaml.so: cannot open shared object file: No such file or directory in Unknown on line 0
Exception: Extension yaml does not exist
Already added
extension=yaml.so
in php.ini file
Details:
CentOS release 6.7 (Final)
PHP 5.4.45
SS after I ran upper install commands:
What is the proper way to install yaml support in php?

php-yaml from epel repository:
php-pecl-yaml-1.1.1-5.el6.x86_64 : Support for YAML 1.1 serialization
using the LibYAML library
Repo : epel
Matched from:
Other: php-yaml
For repo: sudo yum install epel-release
For package: sudo yum install php-yaml
And remember to restart httpd

Related

Php Imagick error: undefined symbol FT_Done_MM_Var, how can i fix it?

Complete output:
Warning: PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /opt/lampp/lib/php/extensions/no-debug-non-zts-20190902/imagick.so (/lib64/libharfbuzz.so.0: undefined symbol: FT_Done_MM_Var), /opt/lampp/lib/php/extensions/no-debug-non-zts-20190902/imagick.so.so (/opt/lampp/lib/php/extensions/no-debug-non-zts-20190902/imagick.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
My OS: Fedora 36
Installed packages: ImageMagick ImageMagick-devel ImageMagick-perl php php-common php-pear php-devel gcc php-imagick.
Imagics.so installed via pecl in xampp
Ok, to install imagick on xampp on fedora you need to type the following commands:
sudo dnf install ImageMagick ImageMagick-devel ImageMagick-libs ImageMagick-perl
sudo dnf install php-pecl-imagick php-pecl-imagick-devel
sudo /opt/lampp/bin/pecl install imagick
It is important to install ImageMagick instead of ImageMagick7 and install php-pecl-imagick and not php-pecl-imagick-im6 or im7.

PHP7.2 missing intl extension

I'm trying to run php app that use locale_accept_from_http function from intl extension. My php version is 7.2 and I get an error: Call to undefined function locale_accept_from_http();
I was trying:
1. Install extension sudo apt-get install php-intl.
The error is:
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php-intl : Depends: php7.1-intl but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
2. Enable intl extension in php.ini.
I'm getting a warning:
PHP Warning: PHP Startup: Unable to load dynamic library 'intl'
What is the right way to use this extension with php7.2?
As it states in your error, you are having broken packages so in that case, you should try to fix it, probably following commands will fix them.
apt update
apt autoremove
Once you have fixed that issue, you can try executing following commands if you have not added ondrej PPA:
add-apt-repository -y ppa:ondrej/php
apt install php7.2 php7.2-intl

PHP Warning: PHP Startup: Unable to load dynamic library 'sqlsrv.so'

Hi i recently installed SQL Server on my machine. It has Ubuntu 16.04 LTS OS.
I followed this link to install server extensions for PHP 7.2 and now I'm getting these PHP warnings:
PHP Startup: Unable to load dynamic library 'pdo_sqlsrv.so'(tried: /usr/lib/php/20170718/pdo_sqlsrv.so (/usr/lib/php/20170718/pdo_sqlsrv.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/pdo_sqlsrv.so.so (/usr/lib/php/20170718/pdo_sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Startup: Unable to load dynamic library 'sqlsrv.so' tried: /usr/lib/php/20170718/sqlsrv.so (/usr/lib/php/20170718/sqlsrv.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/sqlsrv.so.so (tried:/usr/lib/php/20170718/sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
I don't know if this will be useful for you wight now, but this was useful for me when I was trying to install sqlsrv dricer for php in my CentOS 8
sudo su
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo
exit
sudo ACCEPT_EULA=Y yum install msodbcsql
sudo yum install unixODBC-devel
yum groupinstall "Development Tools"
sudo yum install php-pear
sudo yum install php-devel
#IF_ERROR:
sudo yum install dnf-plugins-core
sudo yum config-manager --set-enabled powertools
sudo yum install php-devel
#END_IF_ERROR
sudo pecl install sqlsrv pdo_sqlsrv
sudo echo "extension=/usr/lib64/php/modules/sqlsrv.so" >> /etc/php.d/pdo.ini
sudo echo "extension=/usr/lib64/php/modules/pdo_sqlsrv.so" >> /etc/php.d/pdo.ini
Following this steps I execute php -m and I haver sqlsrv and pdo_sqlsrv installed using php 7.2.

Docker PHP5.6 Call to undefined function bindtextdomain()

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.

Error while installing mongo driver for PHP on amazon linux

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()

Categories