Debian 8: 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.
  • MYSQL_PASSWD is password of root user in mysql-server.
#!/bin/sh

set -e

# MediaWiki version will be changed by debian update.
MEDIAWIKI=http://ftp.debian.org/debian/pool/main/m/mediawiki
VERSION=1.27.3
RELEASE=1
MYSQL_VERSION=5.5

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

debian_install_mysql()
{
  cat <<EOF | sudo debconf-set-selections
mysql-server-${MYSQL_VERSION} mysql-server/root_password password ${MYSQL_PASSWD}
mysql-server-${MYSQL_VERSION} mysql-server/root_password_again password ${MYSQL_PASSWD}
EOF
  sudo apt install -y mysql-server
}

debian_install_mediawiki()
{
  sudo apt install -y devscripts

  mkdir mediawiki
  cd mediawiki/
  wget -q ${MEDIAWIKI}/mediawiki_${VERSION}-${RELEASE}.debian.tar.xz
  wget -q ${MEDIAWIKI}/mediawiki_${VERSION}-${RELEASE}.dsc
  wget -q ${MEDIAWIKI}/mediawiki_${VERSION}-${RELEASE}_all.deb
  wget -q ${MEDIAWIKI}/mediawiki_${VERSION}.orig.tar.gz
  tar zxf mediawiki_${VERSION}.orig.tar.gz
  cd mediawiki-${VERSION}/
  tar xf ../mediawiki_${VERSION}-${RELEASE}.debian.tar.xz

  sed -e 's/php-mbstring, php-xml/libapache2-mod-php5/' \
      -e 's/php-/php5-/g' \
      -e 's/php,/php5,/g' \
      -i debian/control
  pkgs=$(dpkg-checkbuilddeps 2>&1 | \
           sed -e 's/.*build dependencies://g' -e 's/([^)]*)//g')
  # shellcheck disable=SC2086
  sudo apt install -y ${pkgs}
  dpkg-buildpackage -us -uc
  sudo dpkg -i ../*.deb || \
    (sudo apt install -f -y && sudo dpkg -i ../*.deb)
  cd ../..
  rm -rf mediawiki

  cd /usr/share/mediawiki
  sudo php maintenance/install.php mediawiki admin \
       --pass "${MEDIAWIKI_PASSWD}" --dbname my_wiki \
       --dbuser root --dbpass ${MYSQL_PASSWD} --scriptpath /mediawiki
}

debian_install_apache()
{
  sudo apt install -y apache2
  sudo mv /etc/apache2/conf-available/mediawiki.conf \
       /etc/apache2/conf-available/mediawiki.conf.orig

  cat <<EOF | sudo tee /etc/apache2/conf-available/mediawiki.conf
<VirtualHost _default_:443>
  SSLEngine on
  SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
  SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

$(sed -e 's/^/  /g' /etc/apache2/conf-available/mediawiki.conf.orig)
</VirtualHost>
EOF

  sudo a2enmod ssl
  sudo a2enconf mediawiki
  sudo systemctl enable apache2
  sudo systemctl restart apache2
}

debian_main()
{
  debian_install_mysql
  debian_install_mediawiki
  debian_install_apache
}

debian_main

2 Access to MediaWiki

Access to the following URL.

https://<server>/mediawiki

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