MediaWiki Install 2022-09-01: Difference between revisions
Line 126: | Line 126: | ||
= Configure Apache = | = Configure Apache = | ||
Next we'll add an Apache config for | Next we'll add an Apache config for wiki-new.domain.com that points to the MediaWiki engine, and another for wiki-static-new.domain.com that points to a static content directory. | ||
== /etc/apache2/sites-available/wiki-new.conf == | == /etc/apache2/sites-available/wiki-new.conf == |
Revision as of 02:46, 4 September 2022
- Previous Version: https://wiki.traxel.com/index.php/MediaWiki_Install_2022-01-22
Notes
Additional Modules
- Survey Extension, should work well for HeatSync
Create a Host
I'm not going to document this part. Pick your favorite hosting service and create a Debian 10 host.
If your provider supports it, get a permanent IP address and point it at the new host. This will let you blow away the host, create a new one, point the IP at the new host, and redo the install without having to update the DNS entry and wait for the cascade.
If your provider has default-deny firewalling, make sure ports 22, 80, and 443 are open, which will allow SSH, HTTP, and HTTPS, respectively.
Note the IP address.
IP: 35.160.237.84
System Update and Core Software
Following is based, in part, on MediaWiki Installation Requirements.
Log in to your host.
Script:
sudo apt update -y sudo apt upgrade -y # the one true editor sudo apt install -y emacs-nox # Apache with TLS support sudo apt install -y apache2 certbot python3-certbot-apache # DB, PHP, and Apache Modules sudo apt install -y mariadb-server php php-mysql libapache2-mod-php # PHP Support for MediaWiki Features: sudo apt install -y php-xml php-mbstring php-apcu php-intl php-cli php-curl # other mediawiki feature support: sudo apt install -y git imagemagick texlive
Retry: On my first pass through, just pasting this to a CLI, it stopped after the second line (upgrade). I then pasted the whole thing into a file and called it with "sh init.sh", and it ran the whole way through. When I nuke this box and come back through I want to try again using the shell script file on the first pass. Worst case you just keep re-calling the script until it makes it through.
MediaWiki Tarball
I am installing from the tarball instead of using the Debian package because other package tools, like RPM or Snap, or other distros than Debian, might put directories in different places. Following the MediaWiki tarball instructions should be close to universal.
$ mkdir tmp $ cd tmp $ wget https://releases.wikimedia.org/mediawiki/1.38/mediawiki-1.38.2.tar.gz
One difference on other distros may be the location of web content directories. Debian puts them in /var/www. Adjust the following commands to match your distro's structure if you're not using Deb 10.
I'm moving the stock Apache site to a directory for static content, and linking mediawiki to the wiki engine directory. The symlink will make it a bit easier to upgrade to the next version of MediaWiki.
$ cd /var/www $ sudo tar -xvzf ~/tmp/mediawiki-1.38.2.tar.gz $ sudo mv html static $ sudo ln -s mediawiki-1.38.2 mediawiki
Configure MariaDB
Pick a username for MediaWiki to use (I'm using wiki_wiki as an example).
Pick a database name (I'm using hsl_wiki as an example).
Pick a password other than "CHANGE THIS PASSWORD".
$ sudo cat > mariadb-wiki-account.sh create database hsl_wiki; grant all on hsl_wiki.* to 'wiki_wiki'@'localhost' identified by 'CHANGE THIS PASSWORD'; flush privileges;
Control-D to write the file.
$ sudo mariadb < mariadb-wiki-account.sh
Then you can verify it worked if you like. (there won't be any tables, but it shouldn't give you an auth error)
$ mariadb -u wiki_wiki -p MariaDB> show tables in hsl_wiki; MariaDB> exit
Configure Temporary DNS
This is assuming that there is a legacy wiki running on wiki.domain.com, and you will be bringing up the new machine with the temporary name wiki-new.domain.com. Once you have the new machine running and validated, you will migrate wiki.domain.com to the new machine.
Go to your domain name registrar and add an A Record for the machine and two CNAME records; one for the wiki engine and one for static content. I'm using "jimbo2" as the machine name, you can use whatever you like.
Type | Host | Value | TTL |
---|---|---|---|
A Record | jimbo2 | 35.160.237.84 | Automatic |
CNAME | wiki-new | jimbo2.traxel.com | Automatic |
CNAME | wiki-static-new | jimbo2.traxel.com | Automatic |
It may take a bit to cascade through your resolvers. If you want to be able to hit it immediately, you can update your /etc/hosts file. Add a line like "35.160.237.84 mediawiki.domain.com" but with your IP and domain, after the localhost mappings.
Configure Apache
Next we'll add an Apache config for wiki-new.domain.com that points to the MediaWiki engine, and another for wiki-static-new.domain.com that points to a static content directory.
/etc/apache2/sites-available/wiki-new.conf
<VirtualHost *:80> ServerName wiki-new.traxel.com ServerAdmin webmaster@localhost DocumentRoot /var/www/mediawiki ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
/etc/apache2/sites-available/wiki-static-new.conf
<VirtualHost *:80> ServerName wiki-static-new.traxel.com ServerAdmin webmaster@localhost DocumentRoot /var/www/static ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Activate Host Configs
Activate the mediawiki conf and bounce the server.
$ sudo a2ensite wiki-static wiki-static-new $ sudo service apache2 restart
Check Sites
Now you should be able to see the two Apache configs at the desired host addresses:
- http://wiki-new.traxel.com/ (should show the MediaWiki logo page with a link to the config script)
- http://wiki-static-new.traxel.com/ (should show the static Apache2 root directory)
If you went through this script quickly, the DNS may not have cascaded yet. You could try editing your /etc/hosts file, or go get a cup of coffee and read Reddit for half an hour, then try again.
Enable TLS (SSL)
To keep your errors easy to diagnose and resolve, do one site at a time and verify / fix errors independently.
$ sudo certbot --apache -d wiki-new.traxel.com
When it asks about redirects, choose, "2: Redirect - Make all requests redirect to secure HTTPS access."
Hit http://wiki-new.traxel.com and verify it redirects to https:// and shows the correct content. If there are any errors, fix them before moving on.
$ sudo certbot --apache -d wiki-static-new.traxel.com
When it asks about redirects, choose, "2: Redirect - Make all requests redirect to secure HTTPS access."
Hit http://wiki-static-new.traxel.com and verify it redirects to https:// and shows the correct content. Fix any errors before moving on.