Ubuntu 18.04: 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.
#!/bin/sh -e<p>&nbsp;</p>

PHP_VERSION=7.2
MYSQL_VERSION=5.7
[ -z "${MYSQL_PASSWD}" ] && \
  MYSQL_PASSWD=mysql
[ -z "${MEDIAWIKI_PASSWD}" ] && \
  MEDIAWIKI_PASSWD=mediawiki_passwd

mysql_install()
{
  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
}

mediawiki_install()
{
  sudo apt install -y mediawiki

  # Create DB table and LocalSettings.php.
  cd /usr/share/mediawiki
  sudo php maintenance/install.php mediawiki admin \
       --pass "${MEDIAWIKI_PASSWD}" --scriptpath /mediawiki \
       --dbuser root --dbpass "${MYSQL_PASSWD}"
}

apache_install()
{
  sudo apt install -y \
       libapache2-mod-php php-xml php-intl imagemagick git

  sudo cp /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 php${PHP_VERSION}
  sudo a2enmod ssl
  sudo systemctl restart apache2
}

mediawiki_main()
{
  mysql_install
  mediawiki_install
  apache_install
}

mediawiki_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