Forem

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/

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay