SQLite で WordPress 6 を新規構築する

投稿日:

WordPress開発コミュニティでは、2022年にバックエンドとして SQLiteを公式サポートする提案 がなされた。現在も対応のための開発が sqlite-database-integration プラグインとして進められている。

この公式プラグインを用いて WordPress 6.6 を 新規に構築する 方法のメモを示す。既存のインストールに対するプラグインの追加ではないので、他のデータベースバックエンドがない環境でも通用するはずだ(例えばさくらのレンタルサーバ ライトプランとか)

dislaimers and notes

  • きちんとしたドキュメントを一切参照していない。単純に勘で進めた。というわけで何か間違っている可能性はある
  • WordPress がバージョンアップした際に、ときおりデータベース スキーマのアップグレードが必要になる場合がある。この際、 WordPressのアップデータがSQLiteに対応しておらず、スキーマ更新も出来なければWordPress本体バージョンのロールバックもできない状態でスタックする場合がある (かつて経験した)

method

  1. WordPress 本体の展開
  2. sqlite-database-integration プラグインのダウンロード
  3. sqlite-database-integration のインストール
    unzip sqlite-database-integration.zip
    cp -r sqlite-database-integration \
      ${wordpress インストールディレクトリ}/wp-content/plugins/
    cp -r sqlite-database-integration/wp-includes/sqlite \
      ${wordpress インストールディレクトリ}/wp-includes/
    cp sqlite-database-integration/db.copy \
      ${wordpress インストールディレクトリ}/wp-content/db.php
    
  4. wp-config.php の設定
    cd ${wordpress インストールディレクトリ}
    cp wp-config-sample.php wp-config.php
    edit ${wordpress インストールディレクトリ}/wp-config.php
    
    # 以下のソルトを https://api.wordpress.org/secret-key/1.1/salt/ で生成して置き換え
    define( 'AUTHKEY',         'put your unique phrase here' );
    define( 'SECUREAUTHKEY',  'put your unique phrase here' );
    define( 'LOGGEDINKEY',    'put your unique phrase here' );
    define( 'NONCEKEY',        'put your unique phrase here' );
    define( 'AUTHSALT',        'put your unique phrase here' );
    define( 'SECUREAUTHSALT', 'put your unique phrase here' );
    define( 'LOGGEDINSALT',   'put your unique phrase here' );
    define( 'NONCESALT',       'put your unique phrase here' );
    
  5. WordPressのディレクトリを公開し、その公開URLにアクセスすればWordPressのインストーラが表示される
    • データベースの設定画面は表示されない(スキップされるはず)。そのままインストールを進めればWordPressがSQLite上で利用可能になる。
    • SQLiteのデータベースは ${wordpress インストールディレクトリ}/wp-content/database/.ht.sqlite に保存されている(このファイルを削除して公開URLにアクセスすれば、再びインストーラが表示される)