CentOS 7: 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.
#!/bin/sh

set -e

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

centos_install_mysql()
{
  sudo yum install -y mariadb-server php-mysqlnd
  sudo systemctl enable mariadb
  sudo systemctl start mariadb
}

centos_install_mediawiki()
{
  F=http://archives.fedoraproject.org
  M=${F}/pub/archive/fedora/linux/releases/22/Everything/source/SRPMS/m
  wget -q ${M}/mediawiki-1.24.2-1.fc22.src.rpm

  sudo yum-builddep -y mediawiki-1.24.2-1.fc22.src.rpm
  rpm -i mediawiki-1.24.2-1.fc22.src.rpm
  rm -f mediawiki-1.24.2-1.fc22.src.rpm
  cd ~/rpmbuild
  # php-devel has json stuff.
  sed -e 's/, php-pecl-jsonc//g' -i SPECS/mediawiki.spec
  rpmbuild --define='_unpackaged_files_terminate_build 0' \
           -ba SPECS/mediawiki.spec
  cd

  pkgs=$(find ~/rpmbuild/RPMS/ -type f)
  # shellcheck disable=SC2086
  sudo yum localinstall -y ${pkgs}
  rm -rf ~/rpmbuild

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

centos_install_apache()
{
  sudo yum install -y mod_ssl

  cat <<EOF | sudo tee -a /etc/httpd/conf.d/mediawiki.conf
Alias /wiki/skins /usr/share/mediawiki/skins
Alias /wiki /var/www/wiki
EOF

  sudo firewall-cmd --add-service=https --permanent
  sudo firewall-cmd --reload
  sudo systemctl enable httpd
  sudo systemctl start httpd
}

centos_main()
{
  centos_install_mysql
  centos_install_mediawiki
  centos_install_apache
}

centos_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