Installing Mediawiki 1.31.3 on OpenBSD 6.5
Contents
Introduction
We'll install a mediawiki that uses sqlite.
Prerequisites
Make sure you have a server, a domain (we'll use w2.mgk.ro
). Make sure you have followed the OpenBSD Post Install Steps.
Install PHP
pkg_add -r php%7.3 php-gd%7.3 php-intl%7.3 php-pdo_sqlite%7.3 pecl73-imagick
Enable required PHP extensions by:
ln -sf /etc/php-7.3.sample/imagick.ini /etc/php-7.3/ ln -sf /etc/php-7.3.sample/gd.ini /etc/php-7.3/ ln -sf /etc/php-7.3.sample/intl.ini /etc/php-7.3/ ln -sf /etc/php-7.3.sample/opcache.ini /etc/php-7.3/ ln -sf /etc/php-7.3.sample/pdo_sqlite.ini /etc/php-7.3/
Configure files
Create site directories:
domain="w2.mgk.ro" mkdir -p -m 775 /var/www/src /var/www/sites /var/www/sites/${domain} /var/www/sites/${domain}/{data,images} mkdir /var/www/htdocs/${domain} chown :staff /var/www/src /var/www/sites /var/www/sites/${domain} chown :wheel /var/www/htdocs/${domain} chown :www /var/www/sites/${domain}/{data,images} chmod +t /var/www/sites/${domain}/images chmod 775 /var/www/sites/w2.mgk.ro/mediawiki*
Download mediawiki, with extensions and skins:
cd /var/www/src ftp https://releases.wikimedia.org/mediawiki/1.31/mediawiki-1.31.3.tar.gz ftp https://extdist.wmflabs.org/dist/extensions/MobileFrontend-REL1_31-289f540.tar.gz ftp https://extdist.wmflabs.org/dist/skins/MinervaNeue-REL1_33-1903d1a.tar.gz
Extract mediawiki, extensions and skins:
tar -xzf mediawiki-1.31.3.tar.gz -C /var/www/sites/${domain} tar -xzf MobileFrontend-REL1_31-289f540.tar.gz -C /var/www/sites/${domain}/mediawiki-1.31.3/extensions tar -xzf MinervaNeue-REL1_33-1903d1a.tar.gz -C /var/www/sites/${domain}/mediawiki-1.31.3/skins
Create site links in htdocs:
ln -sf ../../sites/${domain}/mediawiki-1.31.3 /var/www/htdocs/${domain}/w
Enable services
rcctl enable php73_fpm rcctl start php73_fpm rcctl enable httpd rcctl start httpd
Configure web server
Add aram to the www group:
usermod -G www aram
Create empty httpd.conf file and configure permissions:
touch /etc/httpd.conf chown root:staff /etc/httpd.conf chmod 664 /etc/httpd.conf
Run the MediaWiki installer
Use this initial config:
server "w2.mgk.ro" { listen on * port 80 root "/htdocs/w2.mgk.ro" directory no index location "/w/*.php" { fastcgi socket "/run/php-fpm.sock" } location "/w/mw-config/*.php" { fastcgi socket "/run/php-fpm.sock" } location "/w/" { directory index index.php } location "/w/mw-config/*" { directory index index.php } location "/w/mw-config/images/*" { pass } location "/w/resources/assets/*" { pass } location "/w/resources/lib/*" { pass } location "/w/resources/src/*" { pass } location "/w/skins/*" { pass } location "/w/extensions/*" { pass } location "/images/deleted/*" { block } location "/images/*" { pass } location "/" { block return 301 "http://$SERVER_NAME/w/mw-config" } location "/*" { block } }
Enable and start PHP and httpd:
rcctl enable php73_fpm rcctl start php73_fpm rcctl enable httpd rcctl start httpd
Visit http://w2.mgk.ro/ and run the installer. Use /sites/w2.mgk.ro/data
for the SQLite data directory. Download LocalSettings.php
and upload it to /var/www/htdocs/${domain}/w
scp LocalSettings.php w2.mgk.ro:/var/www/htdocs/w2.mgk.ro/w
The wiki should now work with traditional (long) URLs.
Enable short URLs
Use this httpd.conf to enable short URLs and disable access to the installer.
server "w2.mgk.ro" { listen on * port 80 root "/htdocs/w2.mgk.ro" directory no index location "/w/*.php" { fastcgi socket "/run/php-fpm.sock" } location "/wiki/*" { fastcgi param SCRIPT_FILENAME "/htdocs/w2.mgk.ro/w/index.php" fastcgi socket "/run/php-fpm.sock" } location "/w/" { directory index index.php } location "/w/resources/assets/*" { pass } location "/w/resources/lib/*" { pass } location "/w/resources/src/*" { pass } location "/w/skins/*" { pass } location "/w/extensions/*" { pass } location "/images/deleted/*" { block } location "/images/*" { pass } location "/" { block return 301 "http://$SERVER_NAME/wiki/Main_Page" } location "/*" { block } }
Then edit LocalSettings.php
to enable short URLs:
$wgScriptPath = "/w"; $wgScriptExtension = ".php"; $wgArticlePath = "/wiki/$1"; $wgUsePathInfo = true;
Restart httpd:
doas rcctl restart httpd
You are now done.
Enable mobile support
Edit LocalSettings.php
to enable it (append it at the bottom):
wfLoadExtension( 'MobileFrontend' ); $wgMFAutodetectMobileView = true; $wgMFDefaultSkinClass = 'SkinVector';