This page explains how to install MediaWiki on macOS. MediaWiki offers a robust platform that’s perfect for users seeking a personal knowledge management system. The installation process will cover setting up MariaDB, PHP, Apache 2, and finally MediaWiki itself.
Installation
Install MariaDB
Install MariaDB as a service:
Connect to restore the database:
At the MariaDB prompt:
Run brew services to verify the service started:
Install PHP 7.4
Install PHP as a service:
Run brew services to verify the service started:
For additional configuration, see the php.ini file:
Install Apache 2
Install Apache 2 as a service:
Run brew services to verify the service started:
For additional configuration, see the conf files at:
Install MediaWiki
Download latest version and unzip at /Users/jano/MediaWiki/notes.
Install dependencies
Or, if you want to restore a previous version, see Restore backup.
Configure Apache 2
Edit /opt/homebrew/etc/httpd/httpd.conf:
Create a file /Users/jano/Developer/mediawiki/notes/index.php with the content below and restart Apache 2.
Domain indirection
We’ll use the made-up domain jano.notes to serve the website locally. If we need to relocate to another domain, looking for instances of our made-up domain will facilitate the process.
Add the line below to /etc/hosts. You will need sudo.
Set these values in /Users/jano/Developer/mediawiki/notes/LocalSettings.php:
Set this value in /opt/homebrew/etc/httpd/httpd.conf:
Speed up MediaWiki
File cache
The file cache stores parsed pages, internationalization, and user sessions. This will greatly improve reading unchanged information. Note that if you edit one section of a big page, the other sections remain unchanged, so the edited page will appear faster than without caching. If your MediaWiki shows “Parser profiling data” at the bottom of the page, take a look before and after.
File caching greatly decreases CPU usage using a hosted MediaWiki with a limited CPU quota. The recommended minimum requirement for MediaWiki is 256MB of RAM for a single-computer website and 85MB of storage. Keep this in mind when choosing a hosted installation since increasing your memory may be more effective than increasing your CPU.
The default value of wgMainCacheType is none. Installing Memcached for a personal website is not worth it, and Opcache is not supported, so I will install APCu (APC User Cache).
Because MediaWiki requires PHP 7.4.33 and that version is not maintained in homebrew, I had to install a tap from shivammathur/homebrew-php. This tap lacks the pcre2 header, so I had to install it and add it to the PHP include folder. Be careful here; paths may be different in your machine.
At this point, I could build APCu using PECL:
Configure LocalSettings.php:
PHP opcode cache
OPCache is a cache for compiled PHP code. It ships with a default configuration of 128 MB, which I found was enough for a single user. I explain here how to configure it, but the default settings are fine.
Check OPcache is enabled.
Check the location of the php.ini file:
Edit ext-opcache.ini and add the configuration below. Do not add it in php.ini, or it will be ignored.
Restart Apache
To check the status of OPCache add this opcache.php page to the HTTPD server and load it.