安装了accelerated-mobile-pages之后, 帖子URL后面加 /amp访问页面,报500错误,查了日志 /var/log/php7.1-fpm.log发现后台报错,
$ less /var/log/php7.1-fpm.log
显示PHP Fatal error: Uncaught Error: Class 'DOMDocument' not found
安装php的xml扩展可以解决这个问题。注意PHP 7以后要安装相应版本的,比如我的Debian 9 上面用的php7.1,要安装7.1的扩展:
$ sudo apt-get install php7.1-xml
以下是详细日志:
[22-Apr-2018 11:09:06] WARNING: [pool www] child 16733 said into stderr: "NOTICE: PHP message: PHP Fatal error: Uncaught Error: Class 'DOMDocument' not found in /data/www/ruoguedu.com/wp-content/plugins/accelerated-mobile-pages/includes/vendor/amp/includes/utils/class-amp-dom-utils.php:7"
[22-Apr-2018 11:09:06] WARNING: [pool www] child 16733 said into stderr: "Stack trace:"
[22-Apr-2018 11:09:06] WARNING: [pool www] child 16733 said into stderr: "#0 /data/www/ruoguedu.com/wp-content/plugins/accelerated-mobile-pages/templates/features.php(6101): AMP_DOM_Utils::get_dom_from_content('<div>WordPress\xE6...')"
[22-Apr-2018 11:09:06] WARNING: [pool www] child 16733 said into stderr: "#1 /data/www/ruoguedu.com/wp-includes/class-wp-hook.php(286): ampforwp_amp_component_checker('<div>WordPress\xE6...')"
[22-Apr-2018 11:09:06] WARNING: [pool www] child 16733 said into stderr: "#2 /data/www/ruoguedu.com/wp-includes/plugin.php(203): WP_Hook->apply_filters('<div>WordPress\xE6...', Array)"
[22-Apr-2018 11:09:06] WARNING: [pool www] child 16733 said into stderr: "#3 /data/www/ruoguedu.com/wp-content/plugins/accelerated-mobile-pages/includes/vendor/amp/includes/class-amp-content.php(48): apply_filters('the_content', '<div>WordPress\xE6...')"
[22-Apr-2018 11:09:06] WARNING: [pool www] child 16733 said into stderr: "#4 /data/www/ruoguedu.com/wp-content/plugins/accelerated-mobile-pages/includes/vendor/amp/includes/class-amp-content.php(22): AMP_Content->transform()"
更多WordPress经验,参考 https://www.ruoguschool.com