久しぶりにWordpressのサイトを移設したら色々とエラーになってハマりました。
作業記録をきちんと残しておかなかったのが敗因ですね。
原因は全てPHPのモジュールが不足していたためでした。
サイトにアクセスすると、データベースに接続できないというエラー。
アッはいそうですね…。php-mysqlを入れてないので…。
sudo apt install php-mysql
サイトにアクセスすると、「重大なエラーが発生しました」とだけ表示されました。 「おいおい、何が原因か教えてくれよ」と思うわけですが、nginxのエラーログを見ると以下のようなものが出力されていました。
2025/05/02 01:34:01 [error] 42975#42975: *260 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to undefined function mb_strtolower() in /var/www/example.com/wp-content/plugins/vk-all-in-one-expansion-unit/inc/display-ie-alert.php:12
Stack trace:
#0 /var/www/example.com/wp-content/plugins/vk-all-in-one-expansion-unit/inc/display-ie-alert.php(51): veu_is_ie()
#1 /var/www/example.com/wp-includes/class-wp-hook.php(324): veu_insert_alert()
#2 /var/www/example.com/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#3 /var/www/example.com/wp-includes/plugin.php(517): WP_Hook->do_action()
#4 /var/www/example.com/wp-includes/general-template.php(3224): do_action()
#5 /var/www/example.com/wp-content/themes/liquid-magazine/header.php(190): wp_body_open()
#6 /var/www/example.com/wp-includes/template.php(810): require_once('...')
#7 /var/www/example.com/wp-includes/template.php(745): load_template()
#8 /var/www/example.com/w" while reading response header from upstream, client: 111.217.190.239, server: example.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php-fpm.sock:", host: "example.com", referrer: "<https://example.com/wp-admin/network/about.php>"
VK All in One Expansion Unitが未定義の関数mb_strtolower()を呼んでいるため、エラーになっています。
この関数はphp-mbstringモジュールのものです。
php-mbstringをインストールすることで解決です。
sudo apt install php-mbstring
サイトにアクセスすると、サイトのデザインが崩れていました。
こちらもnginxのエラーログを確認すると以下のようになっていました。
2025/05/02 01:45:56 [error] 44674#44674: *39 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Class "DOMDocument" not found in /var/www/example.com/wp-content/plugins/wordpress-popular-posts/src/Output.php:176
Stack trace:
#0 /var/www/example.com/wp-content/plugins/wordpress-popular-posts/src/Shortcode/Posts.php(248): WordPressPopularPosts\\Output->get_output()
#1 /var/www/example.com/wp-includes/shortcodes.php(434): WordPressPopularPosts\\Shortcode\\Posts->handle()
#2 [internal function]: do_shortcode_tag()
#3 /var/www/example.com/wp-includes/shortcodes.php(273): preg_replace_callback()
#4 /var/www/example.com/wp-content/plugins/wordpress-popular-posts/src/template-tags.php(220): do_shortcode()
#5 /var/www/example.com/wp-content/themes/liquid-magazine/popularposts.php(132): wpp_get_mostpopular()
#6 /var/www/example.com/wp-content/themes/liquid-magazine/index.php(229): liquid_popular_post()
#7 /var/www/example.com/wp-includes/template-loader.php(106): include('...')
#8 /var/www/example.com/wp-blog-header.php(19): require_once('...')
#9 /var/www/m" while reading response header from upstream, client: 35.199.90.14, server: example.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php-fpm.sock:", host: "example.com"
WordPressPopularPostsプラグインがクラスDOMDocumentを使用しようとして見つからないためエラーになっています。
このクラスはphp-xmlモジュールのものです。
php-xmlをインストールすることで解決です。
sudo apt install php-xml
サイトにアクセスすると、レイアウトが崩れ、ログインステータスのところに「このサイトで重大なエラーが発生しました」というメッセージが表示されました。
nginxのエラーログを見ると以下のようなエラーが出ていました。
2025/05/02 02:36:30 [error] 49059#49059: *2 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to undefined function imagecreatetruecolor() in /var/www/example.com/wp-content/plugins/siteguard/really-simple-captcha/siteguard-really-simple-captcha.php:181
Stack trace:
#0 /var/www/example.com/wp-content/plugins/siteguard/classes/siteguard-captcha.php(186): SiteGuardReallySimpleCaptcha->generate_image()
#1 /var/www/example.com/wp-content/plugins/siteguard/classes/siteguard-captcha.php(192): SiteGuard_CAPTCHA->put_captcha()
#2 /var/www/example.com/wp-includes/class-wp-hook.php(324): SiteGuard_CAPTCHA->handler_login_form()
#3 /var/www/example.com/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#4 /var/www/example.com/wp-includes/plugin.php(517): WP_Hook->do_action()
#5 /var/www/example.com/wp-content/plugins/wp-members/includes/class-wp-members-widget.php(280): do_action()
#6 /var/www/example.com/wp-content/plugins/wp-members/includes/class-wp-members-widget.php(115): widget_wpmemwidget->do_sidebar()
#7 /var/www/tmc-obog.co" while reading response header from upstream, client: 111.217.190.239, server: example.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php-fpm.sock:", host: "example.com"
SiteGuardが未定義の関数imagecreatetruecolor()を呼び出してエラーになっています。
この関数はphp-gdのものです。
php-gdをインストールすることで解決です。
sudo apt install php-gd
やっぱり作業記録は大事です。
今回は以上です。