Newsletter
TechAnV Blog
Get updates on security engineering, Rust, eBPF, and DevSecOps. No spam, unsubscribe anytime.
Check your inbox and click the confirmation link to complete your subscription.
How to run MediaWiki with SQLite on a macOS laptop#
Today I got curious about how MediaWiki records page history, so I started digging around and in the process figured out how to run it against a SQLite database on my macOS laptop!
Requirements: PHP#
To run MediaWiki you need PHP and the SQLite drivers. I was surprised to find out I had PHP already (if not I would have tried installing through Homebrew). It turns out it comes pre-installed on your Mac!
1~ % php --version2PHP 7.3.11 (cli) (built: Jun 5 2020 23:50:40) ( NTS )3Copyright (c) 1997-2018 The PHP Group4Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend TechnologiesTo see version information, do this:
1% cd /tmp2% echo '<? phpinfo(); ?>' > index.php3% php -S localhost:80004PHP 7.3.11 Development Server started at Sat Mar 6 20:50:32 20215Listening on http://localhost:80006Document root is /private/tmp7Press Ctrl-C to quit.php -S localhost:8000 runs PHP’s built-in development server, saving you from having to configure Apache.
Then visit http://localhost:8000 to view the PHP info page.
I searched that page for sqlite and found that it had the pdo_sqlite driver installed already. So that should be everything I need to run MediaWiki.
Downloading MediaWiki#
I downloaded the latest version of MediaWiki from their downloads page, unzipped it, ran php -S localhost:8000 and got this error message:

Turns out the latest MediaWiki requires PHP 7.3.19, but the version bundled with my laptop was 7.3.11.
I didn’t want to mess around with upgrading PHP, so I used the compatibility page to figure out the most recent MediaWiki version that would work with PHP 7.3.11. I decided to try MediaWiki 1.31, which can be downloaded from https://releases.wikimedia.org/mediawiki/1.31/?C=S;O=D
Here’s what worked for me:
1% mkdir ~/wiki2% cd ~/wiki3% wget https://releases.wikimedia.org/mediawiki/1.31/mediawiki-1.31.12.zip4% unzip mediawiki-1.31.12.zip5% cd mediawiki-1.31.126% php -S localhost:80007PHP 7.3.11 Development Server started at Sat Mar 6 20:58:21 20218Listening on http://localhost:80009Document root is /Users/simon/wiki/mediawiki-1.31.12Now visiting http://localhost:8000 gave me the interactive setup tool.
I clicked through their wizard, selected SQLite for the database option and told it where I wanted the database to live:

At the end of the wizard it gave me a LocalSettings.php file to drop into my root ~/wiki/mediawiki-1.31.12 directory… and I was done! Didn’t even need to restart the PHP process (because PHP).
I created a page and then ran Datasette against the SQLite databases it was using like this:
1% datasette ~/wiki/data/*.sqlite