2,699 bytes added,
20 May This document contains a walk-through of how to set up MediaWiki on AWS. In total, this process should take about 30 minutes.
=== Getting Started ===
# Use [https://aws.amazon.com/marketplace/pp/prodview-3tokjpxwvddp2 this service] to install MediaWiki to an EC2 instance
# After installing, SSH into the instance. The MediaWiki root files live in <code>/var/www/html</code>, and Apache configuration files live in <code>/etc/apache2</code>
=== Set up A Record ===
In your website DNS, create an A record which points from your desired URL to the IP address of the newly-created EC2 instance. For example:
* '''Host name''': <code>@</code> (for the main domains) or <code>wiki</code> (for subdomains)
* '''Type''': <code>A</code>
* '''Data''': <code>127.0.0.1</code> (use the IP address of the EC2 instance)
=== Installing OpenSSL ===
Roughly follow [https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-20-04 these instructions] to install OpenSSL using LetsEncrypt
# Install certbot
<syntaxhighlight lang="bash">
sudo apt install certbot python3-certbot-apache
</syntaxhighlight>
# Run certbot (you can just select "No redirect"
<syntaxhighlight lang="bash">
sudo certbot --apache
</syntaxhighlight>
# Verify certbot
<syntaxhighlight lang="bash">
sudo systemctl status certbot.timer
</syntaxhighlight>
=== Update Page URLs ===
To get MediaWiki to display pages using the <code>/w/Some_Page</code> URL, modify <code>LocalSettings.php</code>. Replace the line where it says <code>$wgScriptPage = "";</code> with the following:
<syntaxhighlight lang="php">
$wgScriptPath = "";
$wgArticlePath = "/w/$1";
$wgUsePathInfo = true;
</syntaxhighlight>
Next, in <code>/etc/apache2/apache2.conf</code>, add the following section:
<syntaxhighlight lang="text">
<Directory /var/www/html>
AllowOverride all
</Directory>
</syntaxhighlight>
Create a new <code>.htaccess</code> in <code>/var/www/html</code> with the following contents:
<syntaxhighlight lang="text">
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^w/(.*)$ index.php/$1 [PT,L,QSA]
</syntaxhighlight>
Finally, reload Apache2:
<syntaxhighlight lang="bash">
sudo service apache2 reload
</syntaxhighlight>
=== Extras ===
Here are some notes about some extra features you can add on top of MediaWiki.
==== Storing images in S3 with Cloudfront ====
You can use the [https://www.mediawiki.org/wiki/Extension:AWS AWS MediaWiki Extension] to allow users to upload images and files, store them in S3, and serve them through CloudFront.
This process is somewhat involved. I may write notes about how to do this well in the future.