WordPress 5.7へのアップグレードが可能だったのでいつも通り管理画面から実行しました。しかし、「著名がない」といったようなメッセージが一瞬表示され「502 Bad Gateway」のメッセージになりました。
WordPress 5.7にアップグレードでエラー
最近、管理画面からプラグインを最新版へバージョンアップする際にも「502 Bad Gateway」が発生し、更新がうまくいかないことが度々ありました。
そのたびにサーバへログインして、プラグインをいったん削除し、手動で再ダウンロードしてインストールしていました。
今回はWordpress本体の更新でエラーです。
発生したのは2021.03.10 18:11:08です。
エラー発生後はホームページも管理画面もアクセスできません。
/var/log/php-fpm/error.log
[10-Mar-2021 18:11:08] WARNING: [pool www] child 168469 exited on signal 11 (SIGSEGV) after 89592.268460 seconds from start
[10-Mar-2021 18:11:08] NOTICE: [pool www] child 177732 started
[10-Mar-2021 18:11:08] WARNING: [pool www] child 168510 said into stderr: "NOTICE: Access to the script '/var/www/sites/wordpress/wp-admin/images/about-badge.svg' has been denied (see security.limit_extensions)"
[10-Mar-2021 18:11:08] WARNING: [pool www] child 168470 said into stderr: "NOTICE: Access to the script '/var/www/sites/wordpress/wp-admin/images/about-color-palette.svg' has been denied (see security.limit_extensions)"
[10-Mar-2021 18:11:08] WARNING: [pool www] child 168472 said into stderr: "NOTICE: Access to the script '/var/www/sites/wordpress/wp-admin/images/about-header-brushes.svg' has been denied (see security.limit_extensions)"
[10-Mar-2021 18:11:09] WARNING: [pool www] child 168525 exited on signal 11 (SIGSEGV) after 88047.188762 seconds from start
[10-Mar-2021 18:11:09] NOTICE: [pool www] child 177733 started
[10-Mar-2021 18:11:09] WARNING: [pool www] child 177430 exited on signal 11 (SIGSEGV) after 1842.744925 seconds from start
[10-Mar-2021 18:11:09] NOTICE: [pool www] child 177734 started
[10-Mar-2021 18:11:09] WARNING: [pool www] child 168489 said into stderr: "NOTICE: Access to the script '/var/www/sites/wordpress/wp-admin/images/about-badge.svg' has been denied (see security.limit_extensions)"
[10-Mar-2021 18:11:09] WARNING: [pool www] child 168494 said into stderr: "NOTICE: Access to the script '/var/www/sites/wordpress/wp-admin/images/about-color-palette.svg' has been denied (see security.limit_extensions)"
[10-Mar-2021 18:11:19] WARNING: [pool www] child 168471 said into stderr: "NOTICE: PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 24403379616 bytes) in /home/wordpress/wp-includes/load.php on line 1422"
[10-Mar-2021 18:11:19] WARNING: [pool www] child 168521 said into stderr: "NOTICE: PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 8589952920 bytes) in /home/wordpress/wp-includes/load.php on line 1422"
[10-Mar-2021 18:11:22] WARNING: [pool www] child 177732 exited on signal 11 (SIGSEGV) after 14.407059 seconds from start
[10-Mar-2021 18:11:22] NOTICE: [pool www] child 177738 started
[10-Mar-2021 18:11:43] WARNING: [pool www] child 168484 said into stderr: "NOTICE: PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 8589928120 bytes) in /home/wordpress/wp-includes/load.php on line 1422"
[10-Mar-2021 18:11:56] WARNING: [pool www] child 168821 exited on signal 11 (SIGSEGV) after 84388.759148 seconds from start
[10-Mar-2021 18:11:56] NOTICE: [pool www] child 177743 started
/var/log/nginx/error.log
2021/03/10 18:11:08 [error] 1098#1098: *245845 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 220.211.137.153, server: phoenixknight.jp, request: "GET /wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=hoverIntent&ver=5.7 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm-www.sock:", host: "phoenixknight.jp", referrer: "https://phoenixknight.jp/wp-admin/about.php?updated"
2021/03/10 18:11:08 [error] 1098#1098: *245845 FastCGI sent in stderr: "Access to the script '/var/www/sites/wordpress/wp-admin/images/about-badge.svg' has been denied (see security.limit_extensions)" while reading response header from upstream, client: 220.211.137.153, server: phoenixknight.jp, request: "GET /wp-admin/images/about-badge.svg HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm-www.sock:", host: "phoenixknight.jp", referrer: "https://phoenixknight.jp/wp-admin/about.php?updated"
2021/03/10 18:11:08 [error] 1098#1098: *245845 FastCGI sent in stderr: "Access to the script '/var/www/sites/wordpress/wp-admin/images/about-color-palette.svg' has been denied (see security.limit_extensions)" while reading response header from upstream, client: 220.211.137.153, server: phoenixknight.jp, request: "GET /wp-admin/images/about-color-palette.svg HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm-www.sock:", host: "phoenixknight.jp", referrer: "https://phoenixknight.jp/wp-admin/about.php?updated"
2021/03/10 18:11:08 [error] 1098#1098: *245845 FastCGI sent in stderr: "Access to the script '/var/www/sites/wordpress/wp-admin/images/about-header-brushes.svg' has been denied (see security.limit_extensions)" while reading response header from upstream, client: 220.211.137.153, server: phoenixknight.jp, request: "GET /wp-admin/images/about-header-brushes.svg HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm-www.sock:", host: "phoenixknight.jp", referrer: "https://phoenixknight.jp/wp-admin/load-styles.php?c=0&dir=ltr&load%5Bchunk_0%5D=dashicons,admin-bar,wp-components,common,forms,admin-menu,dashboard,list-tables,edit,revisions,media,themes,about,nav-menus,wp-p&load%5Bchunk_1%5D=ointer,widgets,site-icon,l10n,buttons,wp-auth-check,wp-color-picker,media-views&ver=5.7"
2021/03/10 18:11:09 [error] 1098#1098: *245845 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 220.211.137.153, server: phoenixknight.jp, request: "GET /wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=hoverIntent&ver=5.7 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm-www.sock:", host: "phoenixknight.jp", referrer: "https://phoenixknight.jp/wp-admin/about.php"
2021/03/10 18:11:09 [error] 1098#1098: *245845 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 220.211.137.153, server: phoenixknight.jp, request: "POST /wp-admin/admin-ajax.php HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm-www.sock:", host: "phoenixknight.jp", referrer: "https://phoenixknight.jp/wp-admin/about.php"
2021/03/10 18:11:09 [error] 1098#1098: *245845 FastCGI sent in stderr: "Access to the script '/var/www/sites/wordpress/wp-admin/images/about-badge.svg' has been denied (see security.limit_extensions)" while reading response header from upstream, client: 220.211.137.153, server: phoenixknight.jp, request: "GET /wp-admin/images/about-badge.svg HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm-www.sock:", host: "phoenixknight.jp", referrer: "https://phoenixknight.jp/wp-admin/about.php"
2021/03/10 18:11:09 [error] 1098#1098: *245845 FastCGI sent in stderr: "Access to the script '/var/www/sites/wordpress/wp-admin/images/about-color-palette.svg' has been denied (see security.limit_extensions)" while reading response header from upstream, client: 220.211.137.153, server: phoenixknight.jp, request: "GET /wp-admin/images/about-color-palette.svg HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm-www.sock:", host: "phoenixknight.jp", referrer: "https://phoenixknight.jp/wp-admin/about.php"
2021/03/10 18:11:19 [error] 1098#1098: *245845 FastCGI sent in stderr: "PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 8589952920 bytes) in /home/wordpress/wp-includes/load.php on line 1422" while reading response header from upstream, client: 220.211.137.153, server: phoenixknight.jp, request: "GET /wp-admin/plugins.php HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm-www.sock:", host: "phoenixknight.jp", referrer: "https://phoenixknight.jp/wp-admin/about.php"
2021/03/10 18:11:22 [error] 1098#1098: *245845 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 220.211.137.153, server: phoenixknight.jp, request: "GET /wp-admin/about.php HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm-www.sock:", host: "phoenixknight.jp", referrer: "https://phoenixknight.jp/wp-admin/about.php?updated"
2021/03/10 18:11:43 [error] 1098#1098: *245845 FastCGI sent in stderr: "PHP message: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 8589928120 bytes) in /home/wordpress/wp-includes/load.php on line 1422" while reading response header from upstream, client: 220.211.137.153, server: phoenixknight.jp, request: "POST /wp-admin/admin-ajax.php HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm-www.sock:", host: "phoenixknight.jp", referrer: "https://phoenixknight.jp/wp-admin/post.php?post=15938&action=edit"
2021/03/10 18:11:56 [error] 1098#1098: *246405 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 27.127.136.165, server: phoenixknight.jp, request: "GET /try-the-dtcp-ip-media-player-on-windows-10/ HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm-www.sock:", host: "phoenixknight.jp", referrer: "https://www.google.com/"
手動でWordpress 5.7へ更新
管理画面にアクセスできずWordpress本体が壊れた状態です。
バックアップはとっていなかったので、最新版へ手動でアップグレードすることにしました。
以下はさくらインターネットのVPSにrootユーザでリモートログインして作業しています。
最新版のWordpressを入手
WordPressを入手にあるfa-downloadWordPress 5.7をダウンロードを右クリックしてリンクのアドレスをコピーします。
今回はtar.gz版をダウンロードしたかったので「.tar.gzをダウンロード」を右クリックしてリンクのアドレスをコピーしました。
以下のコマンド入力をして、Wordpress 5.7をダウンロードします。
$ cd /root
$ curl -OL https://ja.wordpress.org/latest-ja.tar.gz
wp-includesとwp-adminディレクトリを削除
現在、サーバー上にある「wp-includes」と「wp-admin」を削除します。
$ cd /var/www/sites/wordpress
$ rm -rf wp-includes wp-admin
wp-includesとwp-adminディレクトリを配置
新しいwp-includesとwp-adminディレクトリを配置します。
ダウンロードしたlatest-ja.tar.gzファイルから抽出します。
$ cd /root
$ tar zxvf latest-ja.tar.gz wordpress/wp-includes -C /var/www/sites/wordpress
$ tar zxvf latest-ja.tar.gz wordpress/wp-admin -C /var/www/sites/wordpress
wp-contentディレクトリ内を上書き
新しいwp-contentディレクトリ内のディレクトリとファイルで既存のwp-contentディレクトリ内を上書きします。
あくまでも新しいファイルでの上書きです。wp-contentディレクトリを削除しないでください。
$ tar zxvf latest-ja.tar.gz wordpress/wp-content -C /var/www/sites/wordpress
wordpress直下のファイルを上書き
新しいwordpressディレクトリ内のファイルで既存のwordpress直下のファイルを上書きします。
$ tar zxvf latest-ja.tar.gz wordpress/*.php -C /var/www/sites/wordpress
$ tar zxvf latest-ja.tar.gz wordpress/lisence.txt -C /var/www/sites/wordpress
$ tar zxvf latest-ja.tar.gz wordpress/readme.html -C /var/www/sites/wordpress
アクセス権の変更
tarで展開したファイルのオーナーはシステムに存在しないUID/GIDになっていると思いますので変更します。
$ cd /var/www/sites
$ chown -R nginx:nginx wordpress
以上で、Wordpress 5.7へ更新できています。
管理画面にアクセスして必要であればデータベースの更新が行われます。
ほかにもPCのFTPアプリ(WinSCPなど)からアップロードして更新する方法もあります。
今後もいつ再発するかかわからないため油断ができません。
バックアップを取ってから作業する癖をつけないと後悔しそうです。