DEV Community

Cover image for Portable Wordpress with SQLite instead of MySQL
Fatih Felix Yildiz
Fatih Felix Yildiz

Posted on

2 1

Portable Wordpress with SQLite instead of MySQL

When working with WordPress, there are many occasions you may need a quick spin WordPress environment without dealing with database setup and a web server.

Making WordPress use a SQLite database and run on a native PHP server is surprisingly easy and simple.

I’ve been using this setup for testing plugins, and themes and trash the setup without worrying about it much.

The magic here is mostly automating the installation and configuration of the WordPress instance using wp-cli. It’s very easy to install and run wp-cli from a phar package.

# Install wp-cli
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

# Set up wordpress site
php wp-cli.phar core install\
        --url=http://localhost:8011\
        --title='Test Site'\
        --admin_user=admin\
        --admin_password=admin\
        --admin_email=test@example.com\
        --skip-email

# Tweaking wordpress settings
php wp-cli.phar rewrite structure '/%postname%/' --hard
php wp-cli.phar option update page_for_posts 10

# Installing and activating plugins
php wp-cli.phar plugin install kirki --activate

# Installing and activating theme
php wp-cli.phar theme activate mytheme

# Creating sample content
php wp-cli.phar post create --post_type=post --post_title='A sample post'
Enter fullscreen mode Exit fullscreen mode

You can get the full installer and configuration script here: https://github.com/mfyz/wp-sqlite-installer


This article was first published on my personal blog: https://mfyz.com/portable-wordpress-with-sqlite-instead-of-mysql/

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay