メインコンテンツにスキップ

Ubuntu 18 を Ubuntu 20 にアップグレードする

説明

この記事では、OS を Ubuntu 18.04 から Ubuntu 20.04 にアップグレードする手順について説明します。

アップグレード

警告

オペレーティングシステムをアップグレードする前に、サーバー上のすべてのデータの完全バックアップを作成することを強く推奨します。 これにより、問題が発生した場合の保険となり、緊急時にシステムを復元できます。

重要

OS のアップグレード中のすべてのコマンドは、root ユーザーでサーバーターミナル上から実行します。

設定ファイルを置き換えるというシステムの提案は拒否してください(デフォルトの動作)。

お使いの OS の /etc/apt/sources.list.d 内のリポジトリファイル名は、この手順で使用されているものと異なる場合があります。

  1. /etc/apt/sources.list に正しいリポジトリがあることを確認してください。 Ubuntu 18.04 のリポジトリ一覧は以下で確認できます。
Ubuntu 18 のリポジトリ
### Main repo for Ubuntu bionic
deb http://archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse

### Updates repo for Ubuntu bionic
deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse

### Security repo for Ubuntu bionic
deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted universe multiverse

### Backports repo for Ubuntu bionic
deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse

### Proposed repo for Ubuntu bionic
deb http://archive.ubuntu.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ bionic-proposed main restricted universe multiverse
  1. 現在のすべてのパッケージを最新バージョンに更新します
apt update && apt dist-upgrade
  1. proftpd および apache2 のアップグレード時に発生する可能性のあるエラーを解消する
a2dismod php7.2
sed -e 's/^IdentLookups/#IdentLookups/' -i /etc/proftpd/proftpd.conf
  1. mysql の設定からすべての query-cache エントリを削除し、mysql リポジトリを調整する:
sed -i 's/^query[_,-]cache[^ ]*//' /etc/mysql/my.cnf.fastpanel/99-fastpanel.cnf
  1. 更新を実行します
do-release-upgrade --allow-third-party

何らかの理由でユーティリティがインストールされていない場合は、次のコマンドで修正できます

apt install update-manager-core
重要

確認する前にユーティリティの出力を注意深く読み、処理中に不要なものが削除されないことを確認してください。

システムからサーバーの再起動を求められた場合、アップグレードは成功したと見なされます。

再起動を承諾します

  1. 基本モジュール、PHP7.4-FPM、および Apache2 用モジュールを含む PHP 7.4 をインストールします
apt-get install -f php php-fpm libapache2-mod-php libapache2-mod-php7.4 php-common php7.4-cgi php7.4-cli php7.4-common php7.4-curl php7.4-gd php7.4-json php7.4-mbstring php7.4-mysql php7.4-opcache php7.4-readline php7.4-xml php7.4-xmlrpc php-imagick php-memcached

phpenmod calendar ctype curl dom exif fileinfo ftp gd gettext json iconv mbstring mysqli mysqlnd pdo pdo_mysql phar posix readline shmop simplexml sockets sysvmsg sysvsem sysvshm tokenizer xml xmlreader xmlrpc xmlwriter xsl opcache imagick memcached
  1. PHP-FPM の設定を置き換えます
mv /opt/php74/etc/php-fpm.d/* /etc/php/7.4/fpm/pool.d/
rm /etc/php/7.2/fpm/pool.d/www.conf
mv /etc/php/7.2/fpm/pool.d/* /etc/php/7.4/fpm/pool.d/
  1. FASTPANEL ベース内の PHP バージョンを修正します
sqlite3 /usr/local/fastpanel2/app/db/fastpanel2.db "update site set php_version = 74 where mode = 'mpm_itk';"
  1. メール受信に必要な Dovecot コンポーネントをインストールします
apt install dovecot-lmtpd
  1. サービスを再設定します
mogwai services configure -f
  1. 使用しているデータベースサーバーに応じた追加設定

MySQL 8 の場合 - 互換性設定を追加します

echo 'disable-log-bin
mysqlx = OFF
default-authentication-plugin = mysql_native_password
character-set-server = utf8
collation-server = utf8_unicode_ci
' >> /etc/mysql/my.cnf.fastpanel/99-fastpanel.cnf

MariaDB の場合 - mysql_upgrade を実行します

mysql_upgrade
  1. サーバーを再起動します
reboot
  1. 再起動後にすべてのサービスが起動していることを確認します
systemctl --failed

アップグレードが完了しました。