PHP 7.2 and modules 'dom', 'mbstring', and 'simplexml' - php

I installed PHP 7.2 on my server and everything works fine except these three issues:
I face these problems:
The PHP extension dom is not loaded. Please contact your server
administrator or visit http://php.net/manual/en/dom.installation.php
for installation.
PHP extension mbstring is not loaded. Please contact your server
administrator or visit
http://php.net/manual/en/mbstring.installation.php for installation.
PHP extension simplexml is not loaded. Please contact your server
administrator or visit
http://php.net/manual/en/simplexml.installation.php for installation.
...
Now when I type php -m,
[root#localhost php.d]# php -m
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
ldap
libxml
mcrypt
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
readline
Reflection
session
sockets
SPL
sqlite3
standard
tokenizer
zlib
[Zend Modules]
[root#localhost php.d]#
It shows that there isn't any mbstring, dom or simplexml modules.
I've tried everything that I can find on google, but I can't seem to install those three modules.
php -v returns this:
PHP 7.2.7 (cli) (built: Jun 20 2018 08:21:26) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
What's wrong?

Try installing the missing modules as:
sudo yum install php7.2-dom
sudo yum install php7.2-mbstring
sudo yum install php7.2-simplexml
Don't forget to restart server after installation.

This may be weird, but once you install these (below commands) depending on your version (mine is 7.3 at the time of post), the modules get enabled somehow.
apt-get install php7.3
apt-get install php7.3-common
apt-get install php7.3-cli
service apache2 restart
php -m

Related

oci8.so is missing in php modules in Linux Centos 8

I'm having a problem to install oracle instant client in my linux server. Its already 5 days i'm stuck with it. I followed the tutorial but still didn't work.
https://medium.com/#azharnian/cara-install-oci8-php-7-di-centos7-851abbb5d15
https://gist.github.com/Yukibashiri/cebaeaccbe531665a5704b1b34a3498e
https://docs.oracle.com/en/database/oracle/oracle-database/19/lnoci/instant-client.html#GUID-96F664E7-AD1D-4FE4-BCE2-6D9687016A51
I've successfully install apache, php and mariaDB in server. I have no problem running my php and laravel in the server.
But my current problem when I install oracle instant client, i notice that oci8.so in /usr/lib64/php/modules is missing. When I run command pear download pecl/oci8 Error as below.
PHP Warning: PHP Startup: Unable to load dynamic library 'oci8.so' (tried: /usr/lib64/php/modules/oci8.so (/usr/lib64/php/modules/oci8.so: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/oci8.so.so (/usr/lib64/php/modules/oci8.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
intl
json
ldap
libxml
mbstring
mcrypt
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
How can I installed oci8.so in my php modules ? How can I check my OCI status.
Appreciate if someone can help me to solve this issue. Many thanks.
https://linux.uits.uconn.edu/2020/03/06/php-and-oci8-installation-for-rhel8/
This link is a step by step on how to install oci8
dnf install oracle-instantclient18.5-basic-18.5.0.0.0-3.x86_64.rpm oracle-instantclient18.5-devel-18.5.0.0.0-3.x86_64.rpm oracle-instantclient18.5-sqlplus-18.5.0.0.0-3.x86_64.rpm
dnf install libnsl
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm
Install PHP and OCI8:
dnf module list php
dnf module enable php:remi-7.4 -y
(if you get the following message: “The operation would result in switching of module 'php' stream '7.2' to stream 'remi-7.4’”)
dnf module reset php (enter “y”)
dnf module enable php:remi-7.4 -y
dnf install -y php php-cli php-common php-fpm php-pear gcc curl-devel php-devel zlib-devel pcre-devel php-pecl-http systemtap-sdt-devel
export PHP_DTRACE=yes
setenforce 0
echo "instantclient,/usr/lib/oracle/18.5/client64/lib" | pecl install oci8-2.2.0.tgz
echo extension=oci8.so >> /etc/php.ini
echo extension=oci8 > /etc/php.d/20-oci8.ini
systemctl restart php-fpm
systemctl restart httpd

laravel artisan migrate give Mcrypto error in php 7.2 (CLI)

I have new in laravel I have set up laravel 5.5 in my system and its installed but when i start to use php artisan migrate its give error
Mcrypt PHP extension required
But when I run the phpinfo on browser there is mcrypt enable but its show the
PHP Version 7.1.12
But in terminal when I run the
php -v
its result
PHP 7.2.2-3+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Feb 6 2018 16:11:23) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.2-3+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
I think Mycrypt not installed in the cli php
How can I fix it and make a laravel project
Thanks in advance
As it mentioned here: https://stackoverflow.com/a/37761637/8489245
You can try to install it with :
sudo apt-get update
sudo apt-get install mcrypt php7.2-mcrypt
sudo apt-get upgrade
if php7.2-mycrypt does not exist you can try to go back to version 7-0 of php and install it with :
sudo apt-get install mcrypt php7.0-mcrypt
Hope it help you!
mcrypt was deprecated in php7.1 and removed in 7.2.
From the release notes of Laravel 5.1:
In previous versions of Laravel, encryption was handled by the mcrypt PHP extension. However, beginning in Laravel 5.1, encryption is handled by the openssl extension, which is more actively maintained.
So you should be using openssl_encrypt, libsodium or another supported library.
Currently enabled modules:
$ php -m
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
fileinfo
filter
ftp
gd
hash
iconv
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
soap
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache

How to enable php5-redis using cli?

I have a docker container where I see all php modules:
root#7b995118fc27:~# php -m
[PHP Modules]
Core
ctype
curl
date
dom
ereg
fileinfo
filter
ftp
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib
[Zend Modules]
As we can see there is no php5-redis in that list.
When I try to install it I get a message saying it is already installed:
root#7b995118fc27:~# apt-get install php5-redis
Reading package lists... Done
Building dependency tree
Reading state information... Done
php5-redis is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.
My php version is 5.6
root#7b995118fc27:~# php -v
PHP 5.6.31 (cli) (built: Sep 15 2017 01:12:36)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
So the only conclusion (if Im not wrong) is that the php5-redis is installed but not enabled.
This is what I have in the Dockerfile:
FROM php:5-apache
RUN a2enmod rewrite
RUN a2enmod expires
RUN service apache2 restart
RUN apachectl -M
RUN apt-get update
RUN apt-get install -y php5-redis
RUN apt-get install -y redis-server
RUN php -m
COPY src/ /var/www/html
EXPOSE 80
CMD ["redis-server"]
So, how can I enable php5-redis in this scenario?
You would need to add below statement to enable the redis extension
RUN cp /etc/php5/mods-available/redis.ini /usr/local/etc/php/conf.d && ln -s /usr/lib/php5/20131226/redis.so /usr/local/lib/php/extensions/no-debug-non-zts-20131226/redis.so

Package 'php5-gd' has no installation candidate

"PHP module gd: Missing" I received such an error. and I'm trying to install php5-gd.
apt-get install php5-gd
I am using Ubuntu 16.10 and PHP version 7. I made all the updates.
When I tried to install php5-gd, I got an error like below.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package php5-gd is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'php5-gd' has no installation candidate
First check which php version you have by sudo php -v. I have php7 so the result is:
PHP 7.0.18-0ubuntu0.17.04.1 (cli) (built: Apr 26 2017 23:59:48) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.18-0ubuntu0.17.04.1, Copyright (c) 1999-2017, by Zend Technologies
since i have php7, I will do the following to list the php packages
sudo apt-cache search php7-*
this returned
libapache2-mod-php7.0 - server-side, HTML-embedded scripting language (Apache 2 module)
php-all-dev - package depending on all supported PHP development packages
php7.0 - server-side, HTML-embedded scripting language (metapackage)
php7.0-cgi - server-side, HTML-embedded scripting language (CGI binary)
php7.0-cli - command-line interpreter for the PHP scripting language
php7.0-common - documentation, examples and common module for PHP
php7.0-curl - CURL module for PHP
php7.0-dev - Files for PHP7.0 module development
php7.0-gd - GD module for PHP
php7.0-gmp - GMP module for PHP
php7.0-json - JSON module for PHP
php7.0-ldap - LDAP module for PHP
php7.0-mysql - MySQL module for PHP
php7.0-odbc - ODBC module for PHP
php7.0-opcache - Zend OpCache module for PHP
php7.0-pgsql - PostgreSQL module for PHP
php7.0-pspell - pspell module for PHP
php7.0-readline - readline module for PHP
php7.0-recode - recode module for PHP
php7.0-snmp - SNMP module for PHP
php7.0-sqlite3 - SQLite3 module for PHP
php7.0-tidy - tidy module for PHP
php7.0-xml - DOM, SimpleXML, WDDX, XML, and XSL module for PHP
php7.0-xmlrpc - XMLRPC-EPI module for PHP
libphp7.0-embed - HTML-embedded scripting language (Embedded SAPI library)
php-amqp - AMQP extension for PHP
php-apcu - APC User Cache for PHP
php-gearman - PHP wrapper to libgearman
php-geoip - GeoIP module for PHP
php-gmagick - Provides a wrapper to the GraphicsMagick library
php-gnupg - PHP wrapper around the gpgme library
php-http - PECL HTTP module for PHP Extended HTTP Support
php-igbinary - igbinary PHP serializer
php-imagick - Provides a wrapper to the ImageMagick library
php-libsodium - PHP wrapper for the Sodium cryptographic library
php-mailparse - Email message manipulation for PHP
php-memcache - memcache extension module for PHP
php-memcached - memcached extension module for PHP, uses libmemcached
php-mongodb - MongoDB driver for PHP
php-msgpack - PHP extension for interfacing with MessagePack
php-oauth - OAuth 1.0 consumer and provider extension
php-pinba - Pinba module for PHP
...and do on
now to install packages run the following command with your desired package
sudo apt-get install php7.0-mysql php7.0-gd php7.0-curl php7.0-recode
note:php7.0-mysql php7.0-gd php7.0-curl php7.0-recode are the package that are listed above.
UPDATE
dont forget to restart apache sudo service apache2 reload
You can use the meta-paclaget php-gd, which is an alias of php7.0-gd
sudo apt-get install php-gd
Please check php version and install modules
apt-get update
apt-get install php5.6-gd
If you want other modules then use this command to get all available modules
apt-cache search php5.*
you have php7 installed but you are trying to install a package of php5 that is the problem
Same issue here.
Use RUN rm /etc/apt/preferences.d/no-debian-php in dockerfile
Also you can see here the solution https://hub.docker.com/_/php

How to install bcmath module?

How do I install the bcmath module on a server? I tried
yum update php-bcmath
but it said it found nothing.
Try yum install php-bcmath.
If you still can't find anything, try yum search bcmath to find the package name
ubuntu and php7.1
sudo apt install php7.1-bcmath
ubuntu and php without version specification
sudo apt install php-bcmath
yum install php72-php-bcmath.x86_64
cp /etc/opt/remi/php72/php.d/20-bcmath.ini /etc/php.d/
cp /opt/remi/php72/root/usr/lib64/php/modules/bcmath.so /usr/lib64/php/modules/
systemctl restart httpd
Not sure why I had to go so deep considering the yum install gave me bcmath in phpinfo()
Worked great on CentOS 6.5
yum install bcmath
All my calls to bcmath functions started working right after an apache restart
service httpd restart
Sweet!
When using the official PHP images of Docker, use docker-php-ext-install bcmath.
Source: https://hub.docker.com/_/php?tab=description#php-core-extensions
Was getting call to undefined function bcmod()
yum install php-bcmath
systemctl restart httpd.service
you should then see something similar to /etc/php.d/bcmath.ini listed under phpinfo.
Centos 7
Plesk 12
PHP 5.4.16
If you have installed php 7.1
then this line work on your system.
sudo apt install php7.1-bcmath
check your php version in your system on ubuntu 16.04
php -v
and then result show there..
PHP 7.1.x+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Aug 19 2018
07:16:12) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine
v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.9-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
The following worked for me on Centos 7.4 with PHP 7.1 using remi repository.
First find out which PHP version I have:
[kiat#reporting ~]$ php --version
PHP 7.1.33 (cli) (built: Oct 23 2019 07:28:45) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.33, Copyright (c) 1999-2018, by Zend Technologies
Then search for bcmath extension in remi-php71 repository:
[kiat#reporting ~]$ yum search php71 | grep bcmath
php71-php-bcmath.x86_64 : A module for PHP applications for using the bcmath
php71u-bcmath.x86_64 : A module for PHP applications for using the bcmath
Now install the first matching extension:
[kiat#reporting ~]$ sudo yum --enablerepo=remi-php71 install php-bcmath
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00
.
.
.
Finally, restart php and nginx:
[kiat#reporting ~]$ sudo systemctl restart php-fpm nginx
I found that the repo that had the package was not enabled. On OEL7,
$ vi /etc/yum.repos.d/ULN-Base.repo
Set enabled to 1 for ol7_optional_latest
$ yum install php-bcmath
and that worked...
I used the following command to find where the package was
$ yum --noplugins --showduplicates --enablerepo \* --disablerepo \*-source --disablerepo C5.\*,c5-media,\*debug\*,\*-source list \*bcmath
If you want to enable any extension then you have to install an extension first, extension maybe enabled but not installed, so taking the example of bcmath
yum search php-bcmath
Then ensure the php version in which u want to install this extension
You will get output like after yum search command>>
yum search php-bcmath**
Loaded plugins: fastestmirror, universal-hooks
Loading mirror speeds from cached hostfile
EA4: 66.71.244.18
cpanel-addons-production-feed: 66.71.244.18
base: mirror.nodesdirect.com
epel: mirror.coastal.edu
extras: www.gtlib.gatech.edu
nux-dextop: mirror.li.nux.ro
updates: mirror.jaleco.com
**============================================================== N/S matched: php-bcmath ===============================================================
ea-php54-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
ea-php55-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
ea-php56-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
ea-php70-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
ea-php71-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
ea-php72-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
If I wanna install for php71 then the command will be like yum install ea-php71-php-bcmath.x86_64 or yum install php71-bcmath.
You can install any extension from the above steps.
In Ubuntu PHP 7.3
sudo apt install php7.3-bcmath
To enable bcmath in Arch Linux or Manjaro
Edit php.ini
nano /etc/php/php.ini
Uncomment bcmath (remove semicolon)
extension=bcmath
If you are using Apache server reload the server by
sudo systemctl reload apache.server
Or
sudo systemctl realod httpd
If you don't use Apache
sudo systemctl reload php-fpm.service
To see the activated modules
php -m
To make sure the bcmath is installed and activated, search for it
php -m | grep bcmath
This worked for me install php72-php-bcmath.x86_64
Then,
systemctl restart php72-php-fpm.service
For PHP 7+ version you can use only:
sudo apt install php-bcmath
I just tried below package for php v5.6 and it worked for me.
yum install php56w-bcmath
apt repo have this extension, just run the below command from your terminal ::
sudo apt-get install php7.2-bcmath*
If still anyone is not getting how to install bcmath as it has lots of other dependant modules to install like php7.2-common, etc.
Try using synaptic application, to install the same. fire command.\
sudo apt-get install synaptic
Open the synaptic application and then click on search tab.
search for bcmath
search results will show all the packages depends on php.
Install as per your convenience.
and install with all auto populated dependancies it required to install.
That's it.
For Centos 7 with php7.0
Install CentOS SCLo RH repository: yum install centos-release-scl-rh
Install rh-php71-php-bcmath rpm package: yum install rh-php71-php-bcmath
systemctl restart httpd.service
If you want to install PHP extensions in ubuntu.
first know which PHP version is active.
php -v
After that install needed plugin using this command.
sudo apt install php7.0-bcmath
you can replace php7.0-bcmath to php-PHPVersion-extensionName

Categories