DEV Community

Luciano Federico Pereira
Luciano Federico Pereira

Posted on

Run WordPress on SQLite: A Zero-Server Local Development Revolution

For years, the "Local WordPress" experience has been synonymous with overhead. Whether you use Docker, XAMPP, or dedicated local server apps, you are essentially running a miniature data center just to edit a theme or manage content.

mysqlite changes the paradigm. It allows you to run WordPress locally using SQLite, meaning no MariaDB, no containers, and no background services. Just PHP and a single database file.

The Vision: WordPress as a Portable Folder

The goal of this project isn't necessarily to replace MySQL on high-traffic production servers. Instead, it’s about making WordPress local-first and ultra-portable.

This is the perfect setup for:

  • Headless WordPress: Use WP as a content API for your local Next.js or Astro dev environment without spinning up a database.
  • Static Site Generation (SSG): Build your site locally, generate the static HTML, and deploy to GitHub Pages or Netlify.
  • Instant Sandboxing: Since the entire site (files + DB) lives in one folder, you can Move, Zip, or Git-commit the entire state of the project instantly.

The Technical Achievement: The Nim Translator

Most previous attempts to bring SQLite to WordPress relied on a db.php drop-in that used PHP's preg_replace to try and rewrite SQL queries on the fly. These were notoriously fragile because MySQL and SQLite speak very different dialects.

mysqlite takes a much more sophisticated, low-level approach using Nim.

What the Nim code actually achieves:

The core of this project is a compiled library written in Nim that acts as a structural translator.

  1. Binary-Level Interception: Instead of just swapping text in PHP, it handles the translation at a high-performance level. Nim compiles to C, allowing it to interface directly with system libraries with near-zero latency.
  2. Dialect Mapping: MySQL and SQLite handle things like AUTO_INCREMENT, date formats, and specific index types differently. The Nim logic acts as a "Universal Translator," taking complex MySQL queries and reframing them into valid SQLite logic before they ever touch the disk.
  3. The "Fake" Client: It effectively tricks the WordPress core into thinking it is talking to a full-blown MySQL server, while secretly writing everything to a highly optimized local .sqlite file.

Why Nim? Using Nim was a strategic choice. It offers the performance of C (required for database-level tasks) but with a much safer, modern syntax that makes complex string manipulation and logic mapping manageable.


Why This Beats Containers for Local Dev

Feature Traditional (Docker/MariaDB) mysqlite (Local SQLite)
RAM Usage Significant (Background services) Negligible (PHP only)
Start-up Time 10–30 seconds Instant
Data Storage Hidden in Volumes/DB Servers A single .sqlite file in your folder
Portability Requires Export/Import Copy/Paste the folder

How to Get Started

Since you don't need a database server, the setup is incredibly lean:

  1. Clone the Repo:

    git clone https://github.com/lucianofedericopereira/mysqlite
    
  2. Start the PHP Server:
    Navigate to the directory and run:

    php -S localhost:8000
    
  3. Install: Open your browser. The installation will proceed normally, but you’ll notice you don't need to create a database or a user in a separate management tool.

Final Thought

By decoupling WordPress from the requirement of a dedicated database server, we turn the world’s most popular CMS into a lightweight, file-based tool. It bridges the gap between the power of WordPress and the simplicity of flat-file systems.

Top comments (0)