Hướng dẫn enable php-xml extension centos

Trong kho phần mềm chính thức của CentOS 7 thì PHP 5.4 đã cũ và không còn được các nhà phát triển hỗ trợ, duy trì và cập nhật bản vá lỗi.

Để hỗ trợ cho những tính năng mới cũng như tăng cường khả năng bảo mật, bạn cần phiên bản PHP mới hơn trên hệ thống CentOS 7.

Hiện tại, PHP 7.3 là phiên bản được phát hành mới nhất của PHP. Trong nội dung bài viết này, chúng tôi sẽ hướng dẫn bạn cài đặt các phiên bản PHP 7.x [bao gồm 7.0, 7.1, 7.2 và 7.3] lên hệ thống CentOS & Redhat 7.

Cài đặt PHP 7 trên CentOS

Để cài đặt PHP 7, bạn cần cài đặt và kích hoạt EPEL và Remi repository trên hệ thống CentOS 7 bằng câu lệnh sau:

  • Cài đặt EPEL

# yum install //dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
  • Cài đặt Remi

# yum install //rpms.remirepo.net/enterprise/remi-release-7.rpm

Server của bạn đã được thiết lập để cài đặt PHP từ yum repository. Sử dụng một trong những lệnh bên dưới để cài đặt PHP 7.0, PHP 7.1, PHP 7.2 hoặc PHP 7.3:

## Install PHP 7.3 
# yum --enablerepo=remi-php73 install php

## Install PHP 7.2 
# yum --enablerepo=remi-php72 install php

## Install PHP 7.1 
# yum --enablerepo=remi-php71 install php

## Install PHP 7.0 
# yum --enablerepo=remi-php70 install php

Sau khi tiến trình cài đặt hoàn tất, để kiểm tra lại thông tin phiên bản PHP đang được kích hoạt lên server, bạn sử dụng lệnh:

# php -v

Cài đặt PHP Modules

Sau khi cài đặt một phiên bản PHP 7.x trên server, để cài đặt thêm một số PHP modules cần thiết cho các ứng dụng, bạn sử dụng lệnh bên dưới:

### For PHP 7.3
yum --enablerepo=remi-php73 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt

### For PHP 7.2
yum --enablerepo=remi-php72 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt

### For PHP 7.1
yum --enablerepo=remi-php71 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt 

### For PHP 7.0
yum --enablerepo=remi-php70 install php-xml php-soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt

Bạn có thể sử dụng lệnh bên dưới để tìm những PHP modules khác có sẵn trong yum repository đã được cấu hình:

# yum --enablerepo=remi-php73 search php | grep php73 [For PHP 7.3]

Chúc bạn thành công!

Gửi phản hồi về bài viết này

XML stands for extensible Markup Language, this is a data format for read document interchange on the Web. This extension can helps simple and easily usable tool-set to convert XML to an object.  By default, this package is not installed in your instance or your local machine. So that we walk you through how to install XML-PHP extension on your CentOS and Ubuntu operating systems.

Ubuntu:

sudo apt-get install php-xml

or

sudo apt-get install php7.2-xml

 

CentOS:

sudo yum install php-xml

or

sudo yum install php72-php-xml

Restart the webserver,

If you are using Ubuntu operating system use the command below,

NGINX:

systemct restart nginx.service

Apache:

systemct restart apache2.service

If you are using CentOS operating system use the command below,

NGINX:

systemct restart nginx.service

Apache:

systemct restart httpd.service

Here we cover the fastest, most effective way to get the PHP DOM extension installed on CentOS. If you’ve just found out you need to install this extension, but don’t really know what it is, we’ve included some background first.

What is DOM?

“The Document Object Model [DOM] is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents.” [Source: DOM in Wikipedia.]

What is PHP DOM extension?

“The DOM extension allows you to operate on XML documents through the DOM API with PHP 5.” [Source: Introduction to the PHP DOM Extension on php.net.]

How to install the PHP DOM Extension on CentOS

You will need superuser privileges. Run the following command:

sudo yum install php-xml

Don’t forget to restart Apache so PHP picks up the new extension:

sudo service httpd restart

How to Check PHP DOM is Installed

You can see PHP DOM is installed by creating a simple web page that calls the phpinfo[] function:

When you go to this webpage in a browser, you should see this output for the dom extension if it’s installed:

DOM/XML enabled
DOM/XML API Version 20031129
libxml Version 2.6.26
HTML Support enabled
XPath Support enabled
XPointer Support enabled
Schema Support enabled
RelaxNG Support enabled

Tested on CentOS 5.3.

  • Tags CentOS, PHP

I am trying to install DOM extension in CentOS. Extension Got installed with Dependency with below command and Then I have restarted service.

yum install php-xml 
sudo service httpd restart

but when I am looking in phpinfo[] it is not reflecting and i am getting this runtime error

I have tried some other related answer too but did not get so far. please let me know if i am missing something here Thanks in advance

asked Sep 1, 2021 at 18:47

After multiple tried for the issue. I found out that I have to restart php-fpm where as i was restarting httpd and and other services

sudo systemctl restart php-fpm

answered Sep 1, 2021 at 18:47

Just migrated a PHP site to a new server. However, in /var/log/httpd/error_log, there are errors like

[:error] [pid 2810] [client 61.92.242.24:43372] PHP Fatal error: Class ‘DOMDocument’ not found in /var/www/…/some.php on line 16

How to add PHP DOMDocument extension to httpd in CentOS 7?

You need to install the package php-xml to have DOMCoument support to PHP:

# yum install php-xml

You may need to restart apache/httpd [# apachectl restart].

The package contains:

$ rpm -ql php-xml
/etc/php.d/dom.ini
/etc/php.d/wddx.ini
/etc/php.d/xmlreader.ini
/etc/php.d/xmlwriter.ini
/etc/php.d/xsl.ini
/usr/lib64/php/modules/dom.so
/usr/lib64/php/modules/wddx.so
/usr/lib64/php/modules/xmlreader.so
/usr/lib64/php/modules/xmlwriter.so
/usr/lib64/php/modules/xsl.so

eugenekay at kashpureff dot org

11 years ago

Certain Linux distributions do not have this extension included in the minimum PHP package. It can usually be found in one of the "optional" php-* packages.

For CentOS, you will need to run "yum install php-xml", which provides this extension.

d at duane dot com

10 years ago

On Fedora 16, you can use
yum -y install php-xml
and then be sure to add
extension=dom.so
in the php.ini file for this to work.

Sergey A.

12 years ago

don't forget
extension=dom.so
in extensions.ini
on freebsd

z1mok at yahoo dot com

13 years ago

You need the DOM MODULE installed if you want to use Youtube Data Api with the Zend GData Library.

Otherwise you cannot obtain a valid Upload Form Token.

Anonymous

10 years ago

In Redhat 5.5 using php53 you need to not only install php53-xml but php53-devel as well to install DOMDocument

Chủ Đề