AlmaLinux 9 に Serposcope 2.15 をインストール

Serposcope Enterprise Linux 9
このサイトはアフィリエイト広告(Amazonアソシエイト含む)を掲載しています。
スポンサーリンク

Serposcope 2 を CentOS 7 から AlmaLinux 9 に移行する際に、OpenJDK の互換性で少しハマりましたので記録しておきます。

Serposcope 2.15.0 の導入

Serposcope は最新版のバージョン 3 が出ていますが、バージョン 2 とデータベースの互換性がありません。以前からのデータは残したいので、バージョン 2 系の最終版である 2.15.0 で移行するようにしました。

インストールに関しては、以前の自分の記事を参考にしつつ設定を進めていきます。

Serposcope を SSL のサブディレクトリで運用する
Google のランキングを解析できるツールで、無料の Serposcope を CentOS 7 に導入したので、その記録を残す。構成CentOS Linux release 7.9.2009 (Core)OpenJDK version ...

ただし、サブディレクトリでの運用は面倒な事しかなかったので、Apache でリバースプロキシを使ったサブドメインの運用に変更しています。

OpenJDK 21 のインストール

Serposcope のバージョン 2 系は Java で作られているので OpenJDK が必要になります。

CentOS 7 では OpenJDK 8 (1.8) でしたが、サポート期間を見ると AlmaLinux 9 では OpenJDK 21 を使うのが良さそうです。

dnf install java-21-openjdk
OpenJDK のライフサイクルおよびサポートポリシー - Red Hat Customer Portal
このアーティクルは、Red Hat Enterprise Linux (RHEL) および Windows ディストリビューションに同梱される OpenJDK のライフサイクルおよびサポートポリシーについて説明します。 Sun、Oracle...

Serposcope のダウンロード

公式のダウンロードページ から serposcope-2.15.0.jar をダウンロードします。

今回も /usr/share/serposcope にインストールしていきます。

mkdir /usr/share/serposcope
cd /usr/share/serposcope
wget https://www.serposcope.com/downloads/2.15.0/serposcope-2.15.0.jar

MySQL の準備

以前からのデータを引き継ぎたいので、旧環境のデータベースを phpMyAdmin でエクスポートし、新環境(MariaDB 11.4)にインポートしました。データベースの引っ越しは何の問題もなくできました。

設定ファイル(/usr/share/serposcope/serposcope.conf)を作成し、MySQL への接続設定を記載します。

# path where is stored embedded database and data files
serposcope.datadir=/usr/share/serposcope

# log path
serposcope.logdir=/var/log/serposcope

# alternative database url, mysql example to use mysql :
serposcope.db.url=jdbc:mysql://localhost/serposcope?user=serposcope&password=パスワード&allowMultiQueries=true
#serposcope.db.url=

# additional database options
#serposcope.db.options=
#serposcope.db.debug=

# listen interface
#serposcope.listenAddress=

# listen port
#serposcope.listenPort=

Serposcope のサービス化

スタートアップ用スクリプトの作成

前回同様、スタートアップスクリプトを /usr/local/bin/serposcope-startup.sh として作成しました。

#!/bin/bash
java -Dserposcope.conf=/usr/share/serposcope/serposcope.conf -jar /usr/share/serposcope/serposcope-2.15.0.jar

スタートアップスクリプトに実行権限を付与します。

chmod +x /usr/local/bin/serposcope-startup.sh

Unit 定義ファイルを配置

/etc/systemd/system/serposcope.service を作成し、下記を記述します。

etc/systemd/system/serposcope.service
[Unit]
Description = Serposcope Service
 
[Service]
ExecStart = /usr/local/bin/serposcope-startup.sh
Restart = always
Type = simple
 
[Install]
WantedBy = multi-user.target

Serposcope の起動

systemctl start serposcope

Serposcope を起動したところ、Java のエラーが出て動きませんでした。

java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @68530210

OpenJDK を 8 から 21 にバージョンアップしたので、そのせいだと思われます。

スタートアップスクリプトの修正

いろいろ試したところ、java の起動オプションに --add-opens=java.base/java.lang=ALL-UNNAMED を追加する事でエラーを回避することができました。

#!/bin/bash
java --add-opens=java.base/java.lang=ALL-UNNAMED -Dserposcope.conf=/usr/share/serposcope/serposcope.conf -jar /usr/share/serposcope/serposcope-2.15.0.jar

サービスを自動起動する

サービスをスタートし、無事に起動することが確認できました。

systemctl start serposcope
systemctl enable serposcope

システムが立ち上がった時に自動的に起動するようにもしておきましょう。

リバースプロキシの設定

前回は Nginx でしたが、今回は Apache でリバースプロキシを設定し、管理者の IP アドレスからのみサブドメインでアクセスできるように設定しました。

<VirtualHost *:443>
    ServerName サブドメイン
    <Location />
        Require all denied
        Require local
        Require ip XXX.XXX.XXX.XXX
    </Location>

    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:7134/
    ProxyPassReverse / http://127.0.0.1:7134/
</VirtualHost>

まとめ

大分ニッチな記事になってしまいましたが、Serposcope 公式のインストール手順もバージョン 3 用に更新されてしまったので、誰かの参考になれば幸いです。

追記

2025年1月末より、Google の仕様変更で JavaScript を実行できないスクレイピングが遮断されるようになりました。今回インストールしたした Serposcope もその影響を受けて検索順位の取得ができなくなってしまったので、使用を中止しました。

systemctl stop serposcope
systemctl disable serposcope

今後はおとなしく、Google Search Console(サーチコンソール)を使うのが良さそうです。

Google Search Console

コメント

タイトルとURLをコピーしました