Difference between revisions of "Setting Up MediaWiki on AWS"

From Humanoid Robots Wiki
Jump to: navigation, search
(Created page with "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.amaz...")
 
(Enabling LaTeX)
 
(One intermediate revision by the same user not shown)
Line 73: Line 73:
  
 
This process is somewhat involved. I may write notes about how to do this well in the future.
 
This process is somewhat involved. I may write notes about how to do this well in the future.
 +
 +
==== Enabling LaTeX ====
 +
 +
* Install the <code>REL1_31</code> branch of the [https://www.mediawiki.org/wiki/Extension:Math Math] extension to the <code>extensions</code> directory
 +
<syntaxhighlight lang="bash">
 +
sudo git clone -b REL1_31 --single-branch --depth 1 https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
 +
</syntaxhighlight>
 +
* Enable the extension in <code>LocalSettings.php</code>
 +
<syntaxhighlight lang="php">
 +
wfLoadExtension('Math');
 +
</syntaxhighlight>
 +
* Run the update script
 +
<syntaxhighlight lang="bash">
 +
sudo php maintenance/update.php
 +
</syntaxhighlight>

Latest revision as of 18:31, 21 May 2024

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[edit]

  1. Use this service to install MediaWiki to an EC2 instance
  2. After installing, SSH into the instance. The MediaWiki root files live in /var/www/html, and Apache configuration files live in /etc/apache2

Set up A Record[edit]

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: @ (for the main domains) or wiki (for subdomains)
  • Type: A
  • Data: 127.0.0.1 (use the IP address of the EC2 instance)

Installing OpenSSL[edit]

Roughly follow these instructions to install OpenSSL using LetsEncrypt

  1. Install certbot
sudo apt install certbot python3-certbot-apache
  1. Run certbot (you can just select "No redirect"
sudo certbot --apache
  1. Verify certbot
sudo systemctl status certbot.timer

Update Page URLs[edit]

To get MediaWiki to display pages using the /w/Some_Page URL, modify LocalSettings.php. Replace the line where it says $wgScriptPage = ""; with the following:

$wgScriptPath = "";
$wgArticlePath = "/w/$1";
$wgUsePathInfo = true;

Next, in /etc/apache2/apache2.conf, add the following section:

<Directory /var/www/html>
        AllowOverride all
</Directory>

Create a new .htaccess in /var/www/html with the following contents:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^w/(.*)$ index.php/$1 [PT,L,QSA]

Finally, reload Apache2:

sudo service apache2 reload

Extras[edit]

Here are some notes about some extra features you can add on top of MediaWiki.

Storing images in S3 with Cloudfront[edit]

You can use the 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.

Enabling LaTeX[edit]

  • Install the REL1_31 branch of the Math extension to the extensions directory
sudo git clone -b REL1_31 --single-branch --depth 1 https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
  • Enable the extension in LocalSettings.php
wfLoadExtension('Math');
  • Run the update script
sudo php maintenance/update.php