OpenSUSE Leap 42: Install MediaWiki

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

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

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

opensuse_install_mediawiki()
{
  # Install mediawiki from server:/php:/applications repository.
  O=http://download.opensuse.org
  A=${O}/repositories/server:/php:/applications/openSUSE_Leap_42.2/

  sudo zypper ar -f -n Applications ${A} Applications
  sudo zypper -n --gpg-auto-import-keys up
  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
}

opensuse_firewall_open_service()
{
  for t in FW_CONFIGURATIONS_EXT FW_CONFIGURATIONS_DMZ FW_CONFIGURATIONS_INT; do
    sudo sed -e "s/^${t}=\"\(.*\)\"/${t}=\"\1 $1\"/g" \
         -i /etc/sysconfig/SuSEfirewall2
  done
  sudo systemctl restart SuSEfirewall2
}

opensuse_install_apache()
{
  # 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/server.crt
  SSLCertificateKeyFile /etc/apache2/ssl.key/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 a2enflag SSL
  sudo a2enmod ssl
  sudo a2enmod php5

  opensuse_firewall_open_service apache2-ssl
  sudo systemctl enable apache2
  sudo systemctl restart apache2
}

opensuse_main()
{
  opensuse_install_mysql
  opensuse_install_mediawiki
  opensuse_install_apache
}

opensuse_main

2 Access to MediaWiki

Access to the following URL.

https://<server>/wiki

Because the chrome does not have this page's certification, the crome warns the following and cannot to access to this page. You need to click "ADVANCED" and "Proceed to <server> (unsafe)". The other browser will needs the similar way.

0001_YourConnectionIsNotPrivate.png

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.

0002_MediaWiki.png