WordPress で SQLite 3 を使う

WordPressはデータの格納にRDBMSを使用します。

base on https://www.weblio.jp/content/RDBMS

RDBMSとは、リレーショナルデータベースを管理するためのソフトウェアの総称である。
リレーショナルデータベースは、データの一つ一つをカラム(列)と、レコード(行)の中にまとめ、それらをテーブル(表)の中に並べるものである。
リレーショナルデータベースのデータの2次元的広がりを効率的に扱うために用いられる。

だいぶ前に、Lubtechのブログを Codeigniter から WordPress に切り替えた際に、(通常はMySQLが利用されますが)SQLite3 をバックエンドにしました。
※SQLite3は WordPress 正式採用されていないので、DBに密に関係するプラグインなどは使えない可能性があります。

再度、最新の WordPress で SQLite Integration を使う機会があったのですが、追加の手順が必要になっていたのでまとめました。

目次

検証バージョン

  • LAMPサーバ : PHP 7.0
  • WordPress 4.9.4
  • SQLite Integration 1.8.1

概要

base on SQLite Integration — WordPress プラグイン

This plugin enables you to create WordPress based web sites without MySQL database server. All you’ve got to prepare is the Apache web server or the like and PHP with PDO extension. WordPress archive and this plugin in hand, you can build a WordPress web site out of the box.

SQLite Integration is a successor to PDO for WordPress plugin, which unfortunately enough, doesn’t seem to be maintained any more. SQLite Integration uses the basic idea and structures of that plugin and adds some utilities with more features.

このプラグインを使用すると、MySQLデータベースサーバーなしでWordPressベースのWebサイトを作成することができます。準備する必要があるのは、Apache WebサーバーなどとPDO拡張機能付きPHPだけです。 WordPressのアーカイブとこのプラグインを手に入れて、あなたはWordPressのWebサイトを箱から作り出すことができます。

SQLiteの統合は、PDO for WordPress Pluginの後継であり、残念ながらそれ以上は維持されていないようです。 SQLiteインテグレーションは、そのプラグインの基本的なアイデアや構造を使用し、より多くの機能を備えたユーティリティを追加します。

設定

※以下、ベースをCodeigniterからWordPressに切り替えました抜粋

  1. wordpress/wp-content/plugins/ ディレクトリに sqlite-integration をフォルダごと移動
  2. sqlite-integration フォルダの中にある db.php を、wp-conent フォルダにコピー
  3. 「\wordpress\wp-config-sample.php」→「\wordpress\wp-config.php」リネーム
  4. wordpressにアクセスするとインストールされます

※DBファイルは「{wordpress}/wp-content/database/.ht.sqlite」です

エラーメッセージ

ルートにアクセスするとエラーメッセージが表示されます。

Unable to create the required directory! Please check your server settings.

設定変更

アクセス権限を変更すると問題なく「ようこそ」画面が表示されます。

$ sudo chmod 0777 /var/www/html/wp-content/

※なお、権限(0766)だとDBエラーになります

コメントを残す