公式ドキュメント • v4.2.2 • MIT

PurifyCMS 開発者&インストールガイド

データベース不要(JSON)+PurifyVoltキャッシュ+統合ECを備えたPurifyCMS v4.2.2の統合技術ドキュメント。

1. 概要とシステム要件

PurifyCMSはSQLデータベースを一切使わない軽量PHP CMS&ECエンジンです。すべてのデータをアトミックなJSONファイルで管理し、APCuと静的HTMLキャッシュ(PurifyVolt)で高速動作します。

動作要件

  • PHPバージョン: PHP 8.1以上(PHP 8.2以上推奨)
  • Webサーバー: Apache(mod_rewrite有効)または Nginx
  • 必須拡張モジュール: json, session, curl, mbstring, zip
  • 推奨拡張モジュール: apcu(メモリキャッシュ), gd または imagick(WebP自動変換)

2. インストール方法

方法 A — Docker / Docker Compose・Coolify(最速)

リポジトリをクローンしてコンテナを起動します。CoolifyではDockerfileを指定し内部ポートを80に設定するだけです。

bash (Docker)
git clone https://github.com/paimontwo/PurifyCMS.git
cd PurifyCMS
docker compose up -d
# http://localhost:8080

方法 B — Webインストールウィザード(共有サーバー / VDS)

ファイルを公開ディレクトリへ配置し、inc/とtmp/へ書き込み権限を付与してブラウザからアクセスします。

bash (Hosting / VDS)
git clone https://github.com/paimontwo/PurifyCMS.git .
chmod -R 775 inc/ tmp/

方法 C — 手動設定

inc/config.sample.phpをinc/config.phpへコピーし、URL・管理パス・パスワードハッシュを設定して/adminからログインします。

bash (Manual)
cp inc/config.sample.php inc/config.php

3. Nginx・Apache サーバー設定

Apacheは同梱の.htaccessでそのまま動作します。Nginxではinc/・admin_core/・themes/*/src/および.json/.logへの直接アクセスを遮断し、すべてのURLをindex.phpへルーティングする設定が必要です:

nginx.conf
server {
    listen 80;
    server_name yourdomain.com;
    root /var/www/html/purifycms;
    index index.php;

    # Block direct access to core & internal theme source folders
    location ~* ^/(inc|admin_core|themes/[^/]+/src)/ {
        deny all;
        return 403;
    }

    # Block sensitive data & log extensions
    location ~* \.(sqlite|log|ini|json|md|dat|tmp)$ {
        deny all;
        return 403;
    }

    # Pretty URL routing
    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|webp)$ {
        expires 30d;
        add_header Cache-Control "public, no-transform";
    }
}

4. ディレクトリ構成とアーキテクチャ

PurifyCMSはコア・JSONデータ・決済ゲートウェイ・テーマを明確に分離しています:

PurifyCMS v4.2.2 Tree
PurifyCMS/
├── index.php                  # Front controller & router
├── install.php                # Web installation wizard
├── Dockerfile & docker-compose.yml
├── admin_core/                # Admin dashboard (pages, products, orders, themes, security, health)
├── api/
│   ├── contact.php            # Contact form endpoint
│   └── ecommerce/             # checkout.php, callback.php, download.php, order-lookup.php
├── inc/
│   ├── config.php             # Site & eCommerce configuration
│   ├── kernel.php             # PurifyVolt cache engine, i18n (p_lang), bootstrap
│   ├── security.php           # CSRF, brute-force protection, hardened sessions
│   ├── PurifyTrade.php        # Flat-file eCommerce engine
│   ├── PurifyMailer.php       # SMTP & email templates
│   ├── gateways/              # BaseGateway.php (abstract) & PayTR.php
│   └── data/                  # Atomic JSON storage (cache/, ecommerce/, locales/, logs/, stats/)
└── themes/
    └── purifydefault/         # theme.json, src/ (layout, head, navbar, footer), pages/, assets/

5. 設定リファレンス (inc/config.php)

主要なシステム設定はinc/config.phpで定義します:

変数 初期値 説明
$cfg_mainurl http://localhost プロトコルを含むサイトのベースURL。
$cfg_admin_path admin 管理画面のカスタムURLスラッグ。
$cfg_admin_ips "" (制限なし) 管理画面アクセスを許可するIP一覧(カンマ区切り)。
$cfg_trust_proxies false Cloudflare等のリバースプロキシ配下ではtrueに設定。
$cfg_active_theme purifydefault themes/配下の有効なテーマフォルダ名。
$cfg_readonly_mode false ファイル書き込みを一時ロックする読み取り専用モード。
$cfg_maintenance_mode false 一般訪問者へメンテナンス画面を表示。
$cfg_enable_ecommerce true Purify Commerce ECエンジンの有効/無効。
$cfg_paytr_m_id / key / salt "" 内蔵PayTR決済ゲートウェイの認証情報。

6. テーマ開発とビジュアルエディタゾーン

themes/purifydefaultはシステム標準テーマのため、独自テーマは必ず別名フォルダへ複製しtheme.jsonを編集してください。ページはsrc/layout.php内の$page_contentに描画され、編集可能ブロックは専用コメントで定義します:

themes/mytheme/pages/about.php
<?php
$title = p_lang('about_title', 'About Us');
$desc  = p_lang('about_desc', 'Learn more about our company.');
?>

<!-- purify:zone:about_hero_start -->
<section class="hero">
    <h1><?= htmlspecialchars($cfg_name ?? 'PurifyCMS') ?></h1>
    <p><?= p_lang('about_intro', 'Fast, flat-file publishing.') ?></p>
</section>
<!-- purify:zone:about_hero_end -->

7. PurifyVoltキャッシュと多言語対応 (i18n)

PurifyVoltはメモリ内のAPCuとinc/data/cache/の静的HTMLを組み合わせた2層キャッシュです。更新時にはPurifyVolt::flushHtml()が自動実行されます。多言語辞書はinc/data/locales/のJSONからp_lang('key', 'Default')で読み込みます。

8. Purify Commerceと決済ゲートウェイ

統合ECエンジン(inc/PurifyTrade.php)は物理・デジタル商品の販売に対応し、api/ecommerce/配下にチェックアウト・コールバック・ダウンロード・注文照会APIを備えています。独自の決済プロバイダはinc/gateways/BaseGateway.phpのPurifyPaymentGatewayを継承して実装できます:

inc/gateways/CustomGateway.php
<?php
require_once __DIR__ . '/BaseGateway.php';

class CustomGateway extends PurifyPaymentGateway {
    public function getToken($order_id, $amount, $customer, $items) {
        // Initialize payment session and return token/redirect payload
        return ['status' => 'success', 'redirect_url' => '...'];
    }

    public function verifyCallback($post_data) {
        // Verify HMAC / webhook signature from payment provider
        return true;
    }
}

9. セキュリティ・バックアップ・リリースノート

  • 組み込みセキュリティ (inc/security.php): CSRFトークン検証、ブルートフォース対策、セッション保護、CAPTCHA、カスタム管理URL、IP制限を標準装備。
  • ワンクリックZIPバックアップ: 管理画面からサイトデータ・テーマ・注文データをZIPで一括エクスポート可能。
  • v4.2.2(最新 — 2026年11月30日): PurifyCMS & CommerceがMITライセンスで100%オープンソース化。Docker/Coolify対応、PurifyVoltキャッシュ強化、Commerce v4を収録。