解决导入XML失败

任务

解决导入时错误:您的站点遇到了致命错误,请查看您的站点的管理电子邮箱来获得指引。

过程

开启调试

通过修改配置文件wp-config.php

开启调试模式

查看报错

Fatal error: Uncaught Error: Class 'DOMDocument' not found in /usr/share/nginx/html/wordpress/wp-content/plugins/wordpress-importer/parsers/class-wxr-parser-simplexml.php:18 Stack trace: #0 /usr/share/nginx/html/wordpress/wp-content/plugins/wordpress-importer/parsers/class-wxr-parser.php(17): WXR_Parser_SimpleXML->parse('/usr/share/ngin...') #1 /usr/share/nginx/html/wordpress/wp-content/plugins/wordpress-importer/class-wp-import.php(1218): WXR_Parser->parse('/usr/share/ngin...') #2 /usr/share/nginx/html/wordpress/wp-content/plugins/wordpress-importer/class-wp-import.php(177): WP_Import->parse('/usr/share/ngin...') #3 /usr/share/nginx/html/wordpress/wp-content/plugins/wordpress-importer/class-wp-import.php(55): WP_Import->handle_upload() #4 /usr/share/nginx/html/wordpress/wp-admin/admin.php(346): WP_Import->dispatch() #5 {main} thrown in /usr/share/nginx/html/wordpress/wp-content/plugins/wordpress-importer/parsers/class-wxr-parser-simplexml.php on line 18

通过搜索,明白需要安装关于php的DOM扩展:php-xml

文档对象模型(DOM)是HTML和XML文档的编程接口。

安装PHP-XML

yum install php-xml

但会报错:

Error: php72w-common conflicts with php-common-5.4.16-43.el7_4.x86_64

根据这篇有用的回答,解决方式是:

yum install php72w-xml

确定已经安装成功

需要有这几个modules(模块)

此时,必须要重启你的php服务:

systemctl restart php-fpm

导入成功!

Leave a comment

Your email address will not be published. Required fields are marked *