OpenSUSE Leap 15: Install MediaWiki for wiki software

This article will describe installing MediaWiki.

1 Install MediaWiki

  • Changing open port of firewall from https to http, you can connect via http.
  • MEDIAWIKI_PASSWD is password of admin user in mediawiki.
#!/bin/sh -e


[ -z "${MEDIAWIKI_PASSWD}" ] && \
  MEDIAWIKI_PASSWD=mediawiki

mysql_install()
{
  sudo zypper -n in mariadb
  sudo systemctl enable mysql
  sudo systemctl start mysql
}

mediawiki_install()
{
  # Mediawiki needs /usr/bin/hhvm.
  # Install hhvm from community package.
  O=http://download.opensuse.org
  A=${O}/repositories/home:/munix9/openSUSE_Leap_15.0/
  sudo zypper ar -f -n munix9 ${A} munix9
  sudo zypper -n --gpg-auto-import-keys ref
  sudo zypper -n in hhvm

  # Install mediawiki from server:/php:/applications repository.
  O=http://download.opensuse.org
  A=${O}/repositories/server:/php:/applications/openSUSE_Leap_15.0/
  sudo zypper ar -f -n Applications ${A} Applications
  sudo zypper -n --gpg-auto-import-keys ref
  sudo zypper -n in mediawiki

  # install.php will create DB table and LocalSettings.php.
  cd /usr/share/mediawiki
  sudo php maintenance/install.php mediawiki admin \
       --pass ${MEDIAWIKI_PASSWD} --dbname my_wiki --dbuser root
  sudo ln -s /usr/share/mediawiki/LocalSettings.php \
       /var/lib/mediawiki/webroot/LocalSettings.php
}

apache_install()
{
  sudo zypper -n in apache2
  sudo systemctl enable apache2

  # Generate crt and key file.
  sudo gensslcert

  # Convert 2.2 conf to 2.4 conf and add https support.
  sudo mv /etc/apache2/conf.d/mediawiki.conf \
       /etc/apache2/conf.d/mediawiki.conf.orig
  cat <<EOF | sudo tee /etc/apache2/conf.d/mediawiki.conf
<VirtualHost *:443>
  SSLEngine on
  SSLCertificateFile /etc/apache2/ssl.crt/$(hostname -f)-server.crt
  SSLCertificateKeyFile /etc/apache2/ssl.key/$(hostname -f)-server.key

  Alias /wiki /var/lib/mediawiki/webroot

$(sudo sed -e 's/Allow From All/Require all granted/g' \
           -e 's/Deny from all/Require all denied/g' \
           -e 's;^[^#]\(.*\)Alias;#\1Alias;g' \
           /etc/apache2/conf.d/mediawiki.conf.orig)
</VirtualHost>
EOF

  sudo firewall-cmd --add-service=https --permanent
  sudo firewall-cmd --reload

  sudo a2enflag SSL
  sudo a2enmod ssl
  sudo a2enmod php7
  sudo systemctl restart apache2
}

opensuse_main()
{
  mysql_install
  mediawiki_install
  apache_install
}

opensuse_main

2 Access to MediaWiki

Access to the following URL. Accept this page's certification to browser.

https://<server>/mediawiki

MediaWiki is displayed. Click "Log in" at the top right, and input admin to user and MEDIAWIKI_PASSWD value to password. Then you can login to MediaWiki.

0001_MediaWiki.png