カテゴリー: Linux

  • Ubuntu ServerのOSをアップグレードしたら、WordPressでエラー

    Ubuntu ServerのOSを、20.04から、22.04、24.04と同じ日にアップデートを実施した。実施のときにPHPのバージョンも変わったので、いろいろと対処した。Wordpressの表示もできるようになったのだが・・・管理画面にログインしようとしたら、下記のエラーが。

    エラー詳細
    ===============
    エラータイプ E_ERROR が /var/www/html/sitename/wp-content/themes/muum_tcd085/functions/theme-setup.php ファイルの 65 行目で発生しました。 エラーメッセージ: Uncaught Error: Call to undefined function simplexml_load_string() in /var/www/html/sitename/wp-content/themes/muum_tcd085/functions/theme-setup.php:65
    Stack trace:
    #0 /var/www/html/sitename/wp-content/themes/muum_tcd085/functions/update_notifier.php(15): get_tcd_update_notifier_xml()
    #1 /var/www/html/sitename/wp-includes/class-wp-hook.php(324): tcd_update_notifier_admin_menu()
    #2 /var/www/html/sitename/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    #3 /var/www/html/sitename/wp-includes/plugin.php(517): WP_Hook->do_action()
    #4 /var/www/html/sitename/wp-admin/includes/menu.php(161): do_action()
    #5 /var/www/html/sitename/wp-admin/menu.php(423): require_once('...')
    #6 /var/www/html/sitename/wp-admin/admin.php(159): require('...')
    #7 /var/www/html/sitename/wp-admin/index.php(10): require_once('...')
    #8 {main}
      thrown

    この65行目をみると、

     $xml = simplexml_load_string( $cache_data );

    なので、XML関連ということがわかった。

    php8.3の状況を調べてみると、「php8.3-xml」がインストールされていない。なので、

    sudo apt install php8.3-xml

    で、インストールを行って、再起動。これで管理画面に入れるようになった。

    あと、Wordpressのサイトヘルスから足りていない推奨モジュールを表示して、aptでインストールした。

  • GitLab 17.7.2-ceからGitLab 17.10.3へのapt upgradeがエラーになった。

    ちょっと、GitLabのアップデートをサボっていたところ、GitLab 17.7.2-ceからGitLab 17.10.3へのapt upgradeがエラーになった。

    エラーの内容(↓)

    .../gitlab-ce_17.10.3-ce.0_amd64.deb を展開する準備をしています ...
    gitlab preinstall: It seems you are upgrading from 17.7 to 17.10.
    gitlab preinstall: It is required to upgrade to the latest 17.8.x version first before proceeding.
    gitlab preinstall: Please follow the upgrade documentation at https://docs.gitlab.com/ee/update/index.html#upgrade-paths
    dpkg: アーカイブ /var/cache/apt/archives/gitlab-ce_17.10.3-ce.0_amd64.deb の処理中にエラーが発生しました (--unpack):
     new gitlab-ce package pre-installation script subprocess returned error exit status 1
    処理中にエラーが発生しました:
     /var/cache/apt/archives/gitlab-ce_17.10.3-ce.0_amd64.deb
    E: Sub-process /usr/bin/dpkg returned an error code (1)

    GitLab 17.10.xへのアップデートするために、一度、GitLab 17.8.xに上げる必要があるとのこと。厳密なアップグレードのパスを調べるために、下記の公式サイトで、アップグレードパスをチェックした。

    https://gitlab-com.gitlab.io/support/toolbox/upgrade-path

    これによると、「GitLab 17.8.6」に一度上げる必要があるということで、apt upgradeでバージョン指定をして、実行。コマンドは下記。

    sudo apt upgrade gitlab-ce=17.8.6-ce.0

    GitLab 17.8.6へのアップデートが成功したのを確認して、もう一度、apt update、apt upgradeを行った。

    sudo apt update
    apt list --upgradable
    sudo apt upgrade

    正常終了したらGitlabをリスタートさせて終了。

    sudo gitlab-ctl restart
  • メモ:GitLab 17.3.1-ceから17.4.1-ceはapt updateアップデートできた。

    メモとして。GitLab 17.3.1-ceから17.4.1-ceはapt updateアップデートできた。

  • メモ:GitLab 17.1.1-ceからGitLab 17.3.0-ceへはapt updateでアップデートできた。

    油断すると、GitLab CEのアップデートがapt updateで失敗するので、メモ。

    GitLab 17.1.1-ceからGitLab 17.3.0-ceへはapt updateでアップデートできた。

  • Ubuntu 24.04 LTSにPostgreSQLをインストールしたときのデータファイルの場所

    Ubuntu 24.04に、aptからPostgreSQL(Version 16)をインストールしたときのデータファイルの場所のメモ。

    下記のパスにデータファイルが保存されている。パーミッションが絞り込まれているので、中身をみたい場合はPostgeSQLのユーザにsuしてアクセスする必要がある。

    /var/lib/postgresql/16/main/
  • メモ:GitLab 16.9.2-ceからGitLab 16.10.3-ceへはapt updateでアップデートできた。

    油断すると、GitLab CEのアップデートがapt updateで失敗するので、メモ。

    GitLab 16.9.2-ceからGitLab 16.10.3-ceへはapt updateでアップデートできた。

  • UbuntuでGitLab CEの更新でGPGキーのエラーが出た

    Ubuntu 20.04 LTSで、apt updateでgitlab-ceの更新で、GPGキーのエラーが出た。エラーの原因は、GPGキーの有効期限が2024年3月1日までで、切れたため。その対応メモ。

    出力されたエラーメッセージ

    以下の署名が無効です: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>

    GPGキーの有効期限が2024年3月1日で切れているので、延長するために、下記のコマンドで更新を行った。

    curl -s "https://packages.gitlab.com/gpg.key" | sudo apt-key add -

    apt updateを実行してみると、同じようにエラーが表示された(前回と同じ方法では、うまくいかなかった)。公式の手順の内容を参考にして実行したところ、うまくいった。

    https://docs.gitlab.com/omnibus/update/package_signatures#update-keys-after-expiry-extension

    「signed-by」の機能を使用しているか、コマンドで確認する。

    grep 'deb \[signed-by=' /etc/apt/sources.list.d/gitlab_gitlab-?e.list

    Grepの結果が返される場合は、「signed-by」 を使用しているので、次のAWKコマンドを実行する。これで、GitLabリポジトリの公開鍵を更新する。要root権限。

     sudo awk '/deb \[signed-by=/{
           pubkey = $2;
           sub(/\[signed-by=/, "", pubkey);
           sub(/\]$/, "", pubkey);
           print pubkey
         }' /etc/apt/sources.list.d/gitlab_gitlab-?e.list | \
       while read line; do
         curl -s "https://packages.gitlab.com/gpg.key" | gpg --dearmor > $line
       done

    これで、あとはapt updateを行って、問題が解消しているか確認する。

    以下は、実行ログの抜粋。

    zen@LABO:~$ sudo apt update
    [sudo] zen のパスワード:
    ヒット:2 http://security.ubuntu.com/ubuntu focal-security InRelease
    ヒット:3 http://jp.archive.ubuntu.com/ubuntu focal InRelease
    取得:4 http://jp.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
    ヒット:5 http://jp.archive.ubuntu.com/ubuntu focal-backports InRelease
    取得:1 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease [23.3 kB]
    エラー:1 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease
      以下の署名が無効です: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>
    137 kB を 2秒 で取得しました (59.7 kB/s)
    パッケージリストを読み込んでいます... 完了
    依存関係ツリーを作成しています
    状態情報を読み取っています... 完了
    パッケージはすべて最新です。
    W: 署名照合中にエラーが発生しました。リポジトリは更新されず、過去のインデックス ファイルが使われます。GPG エラー: https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease: 以下の署名が無効です: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>
    W: https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/dists/focal/InRelease の 取得に失敗しました  以下の署名が無効です: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>
    W: いくつかのインデックスファイルのダウンロードに失敗しました。これらは無視され るか、古いものが代わりに使われます。
    zen@LABO:~$
    zen@LABO:~$ curl -s "https://packages.gitlab.com/gpg.key" | sudo apt-key add -
    OK
    zen@LABO:~$
    zen@LABO:~$ sudo apt update
    [sudo] zen のパスワード:
    ヒット:2 http://jp.archive.ubuntu.com/ubuntu focal InRelease
    ヒット:3 http://security.ubuntu.com/ubuntu focal-security InRelease
    取得:4 http://jp.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
    ヒット:5 http://jp.archive.ubuntu.com/ubuntu focal-backports InRelease
    取得:1 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease [23.3 kB]
    エラー:1 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease
      以下の署名が無効です: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>
    137 kB を 3秒 で取得しました (46.3 kB/s)
    パッケージリストを読み込んでいます... 完了
    依存関係ツリーを作成しています
    状態情報を読み取っています... 完了
    パッケージはすべて最新です。
    W: 署名照合中にエラーが発生しました。リポジトリは更新されず、過去のインデックス ファイルが使われます。GPG エラー: https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease: 以下の署名が無効です: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>
    W: https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/dists/focal/InRelease の 取得に失敗しました  以下の署名が無効です: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>
    W: いくつかのインデックスファイルのダウンロードに失敗しました。これらは無視され るか、古いものが代わりに使われます。
    zen@LABO:~$
    zen@LABO:~$  grep 'deb \[signed-by=' /etc/apt/sources.list.d/gitlab_gitlab-?e.list
    
    deb [signed-by=/usr/share/keyrings/gitlab_gitlab-ce-archive-keyring.gpg] https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/ focal main
    zen@LABO:~$
    zen@LABO:~$
    zen@LABO:~$
    zen@LABO:~$ sudo su
    root@LABO:/home/zen#
    root@LABO:/home/zen#
    root@LABO:/home/zen# awk '/deb \[signed-by=/{
    >        pubkey = $2;
    >        sub(/\[signed-by=/, "", pubkey);
    >        sub(/\]$/, "", pubkey);
    >        print pubkey
    >      }' /etc/apt/sources.list.d/gitlab_gitlab-?e.list | \
    >    while read line; do
    >      curl -s "https://packages.gitlab.com/gpg.key" | gpg --dearmor > $line
    >    done
    root@LABO:/home/zen#
    root@LABO:/home/zen# apt update
    ヒット:2 http://security.ubuntu.com/ubuntu focal-security InRelease
    ヒット:3 http://jp.archive.ubuntu.com/ubuntu focal InRelease
    ヒット:4 http://jp.archive.ubuntu.com/ubuntu focal-updates InRelease
    ヒット:5 http://jp.archive.ubuntu.com/ubuntu focal-backports InRelease
    取得:1 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease [23.3 kB]
    取得:6 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal/main amd64 Packages [54.6 kB]
    78.0 kB を 3秒 で取得しました (22.6 kB/s)
    パッケージリストを読み込んでいます... 完了
    依存関係ツリーを作成しています
    状態情報を読み取っています... 完了
    アップグレードできるパッケージが 1 個あります。表示するには 'apt list --upgradable' を実行してください。
    root@LABO:/home/zen#
  • UbuntuでMariaDBのアップデートがエラーになった

    Ubuntu 20.04 でapt update , apt upgrade を実行したところ、MariaDBの更新でエラーになった。apt cleanや再実行では、解消せず。

    エラーの一部

    dpkg: error processing archive /var/cache/apt/archives/mariadb-server-core-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb (--unpack):

    エラーの全体

    $ sudo apt upgrade
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Calculating upgrade... Done
    The following packages were automatically installed and are no longer required:
      libmariadb3 linux-image-4.15.0-202-generic linux-modules-4.15.0-202-generic
      linux-modules-extra-4.15.0-202-generic
    Use 'sudo apt autoremove' to remove them.
    Get more security updates through Ubuntu Pro with 'esm-apps' enabled:
      libmagickcore-6.q16-6-extra imagemagick libmagickwand-6.q16-6
      imagemagick-6.q16 libopenexr24 libmagickcore-6.q16-6 imagemagick-6-common
    Learn more about Ubuntu Pro at https://ubuntu.com/pro
    The following packages will be upgraded:
      mariadb-server-10.3 mariadb-server-core-10.3
    2 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    168 not fully installed or removed.
    2 standard LTS security updates
    Need to get 0 B/10.5 MB of archives.
    After this operation, 773 kB disk space will be freed.
    Do you want to continue? [Y/n] Y
    Preconfiguring packages ...
    (Reading database ... 132397 files and directories currently installed.)
    Preparing to unpack .../mariadb-server-core-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb ...
    Unpacking mariadb-server-core-10.3 (1:10.3.38-0ubuntu0.20.04.1) over (1:10.3.37+maria~ubu1804) ...
    dpkg: error processing archive /var/cache/apt/archives/mariadb-server-core-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb (--unpack):
     trying to overwrite '/usr/bin/my_print_defaults', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
    dpkg: regarding .../mariadb-server-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb containing mariadb-server-10.3:
     mariadb-server-10.3 conflicts with mysql-server-core-5.5
      mariadb-server-core-10.3 provides mysql-server-core-5.5 and is present and installed.
    dpkg: error processing archive /var/cache/apt/archives/mariadb-server-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb (--unpack):
     conflicting packages - not installing mariadb-server-10.3
    Errors were encountered while processing:
     /var/cache/apt/archives/mariadb-server-core-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb
     /var/cache/apt/archives/mariadb-server-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb
    E: Sub-process /usr/bin/dpkg returned an error code (1)

    強制的に上書きした。パッケージのパスはエラーで表示されたものをそのまま指定して、実行した。

    $ sudo dpkg -i --force-overwrite /var/cache/apt/archives/mariadb-server-core-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb

    実行例。ワーニングやエラーが出ていた。

    $ sudo dpkg -i --force-overwrite /var/cache/apt/archives/mariadb-server-core-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb
    (Reading database ... 132397 files and directories currently installed.)
    Preparing to unpack .../mariadb-server-core-10.3_1%3a10.3.38-0ubuntu0.20.04.1_amd64.deb ...
    Unpacking mariadb-server-core-10.3 (1:10.3.38-0ubuntu0.20.04.1) over (1:10.3.37+maria~ubu1804) ...
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/bin/my_print_defaults', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/bin/resolveip', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/share/man/man1/my_print_defaults.1.gz', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/share/man/man1/resolveip.1.gz', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/share/mysql/fill_help_tables.sql', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/share/mysql/maria_add_gis_sp_bootstrap.sql', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/share/mysql/mysql_performance_tables.sql', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/share/mysql/mysql_system_tables.sql', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/share/mysql/mysql_system_tables_data.sql', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/share/mysql/mysql_test_data_timezone.sql', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: warning: overriding problem because --force enabled:
    dpkg: warning: trying to overwrite '/usr/share/mysql/mysql_test_db.sql', which is also in package mariadb-server-10.3 1:10.3.37+maria~ubu1804
    dpkg: dependency problems prevent configuration of mariadb-server-core-10.3:
     mariadb-server-core-10.3 depends on libsnappy1v5 (>= 1.1.8); however:
      Package libsnappy1v5:amd64 is not configured yet.
    dpkg: error processing package mariadb-server-core-10.3 (--install):
     dependency problems - leaving unconfigured
    Processing triggers for man-db (2.9.1-1) ...
    Errors were encountered while processing:
     mariadb-server-core-10.3
    $

    この後、もう1回、apt updateとapt upgradeを実施した。その他のパッケージもキレイにインストールされた。

    念のため、OS再起動も実施したが起動に問題なし。MariaDBもバージョンアップされていることを確認できた。

  • Gitlab CEをインストールしたUbuntuのOSをアップグレード

    “sudo do-release-upgrade” を実行したところ、”Please install all available updates for your release before upgrading.” が表示された。先にパッケージを最新にしろというので、”sudo apt update” “sudo apt upgarade” でパッケージを最新化した。

    その後、”sudo do-release-upgrade” を実行したところ、rebootを求められたので、再起動を実施した。

    再起動後に、”sudo do-release-upgrade” して、OSはUbuntu 18.04 から Ubuntu 20.04 にアップグレードできた。アップグレードのときに、サードパーティのaptリポジトリが対象から外された。外れたリポジトリは、GitLab CEのリポジトリ。

    Ubuntu 20.04に無事にアップグレードされた後に、apt update を行ったが、gitlab用のリポジトリは対象には入っていなかった。そのため、下記のコマンドで、リポジトリを再登録した。

    curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash 

    その後に、apt update を行い、対象にGitLabのリポジトリが含まれていることを確認した。このとき、アップデート対象に、GitLab CEが含まれていたので、apt upgradeでインストールした。このときの動作は、16.2.0-ce.0から16.2.0-ce.0の同じバージョンでの上書きインストールだった。

    gitlab-ce/focal 16.2.0-ce.0 amd64 [16.2.0-ce.0 からアップグレード可]

    これで無事にアップグレード完了。

  • GitLab CE で小まめにアップデートし忘れて、apt updateでエラーになった。

    すでに何度目かのミス。GitLab CEはアップデートのタイミングが早いので、小まめにアップデートを行っておかないと、アップグレードパスから外れて、apt updateでアップデートできなくなる。下記は、おきまりのエラー表示。

    dpkg: アーカイブ /var/cache/apt/archives/gitlab-ce_16.1.2-ce.0_amd64.deb の処理 中にエラーが発生しました (--unpack):
     new gitlab-ce package pre-installation script subprocess returned error exit status 1
    処理中にエラーが発生しました:
     /var/cache/apt/archives/gitlab-ce_16.1.2-ce.0_amd64.deb
    E: Sub-process /usr/bin/dpkg returned an error code (1)

    今回は、GitLab-ce-15.6.0から、最新のGitLab-ce-16.1.2なので、下記のアップグレードパスを踏んでアップグレードした。

    GitLab-ce-15.6.0

    GitLab-ce-15.11.11 ・・・15系の最終バージョン

    GitLab-ce-16.1.2

    コマンドは、次の順番で実行。これで、無事に16系の最新(作業時最新の16.1.2)にアップデートできた。

    sudo apt update
    sudo apt upgrade gitlab-ce=15.11.11-ce.0
    sudo apt upgrade gitlab-ce=16.1.2-ce.0
    sudo gitlab-ctl restart

    GitLab CEのアップグレードパスについては、下記を参照。

    https://docs.gitlab.com/ee/update/index.html#upgrading-to-a-new-major-version