Download the PHP package edwardspec/mediawiki-aws-s3 without Composer
On this page you can find all versions of the php package edwardspec/mediawiki-aws-s3. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download edwardspec/mediawiki-aws-s3
More information about edwardspec/mediawiki-aws-s3
Files in edwardspec/mediawiki-aws-s3
Package mediawiki-aws-s3
Short Description Allows MediaWiki to use Amazon S3 to store uploaded files.
License GPL-2.0+
Informations about the package mediawiki-aws-s3
Extension:AWS - https://www.mediawiki.org/wiki/Extension:AWS
What it does: it stores images in Amazon S3 instead of the local directory.
Why is this needed: when images are in S3, Amazon EC2 instance which runs MediaWiki doesn't contain any important data and can be created/destroyed by Autoscaling.
Installation
Note: This version of Extension:AWS requires MediaWiki 1.35+. For older versions of MediaWiki (1.27-1.34) use the following instructions instead: https://github.com/edwardspec/mediawiki-aws-s3/blob/REL1_34/README.md
1) Download the extension: git clone --depth 1 https://github.com/edwardspec/mediawiki-aws-s3.git AWS
2) Move the AWS directory to the "extensions" directory of your MediaWiki, e.g. /var/www/html/w/extensions
(assuming MediaWiki is in /var/www/html/w
).
3) Create the file /var/www/html/w/composer.local.json
with the following contents:
4) Run composer update
from /var/www/html/w
(to download dependencies). If you don't have Composer installed, see https://www.mediawiki.org/wiki/Composer for how to install it.
5) Create an S3 bucket for images, e.g. wonderfulbali234
. Note: this name will be seen in URL of images.
6a) If your EC2 instance has an IAM instance profile (recommended), copy everything from "Needed IAM permissions" (see below) to inline policy of the IAM role. See https://console.aws.amazon.com/iam/home#/roles
6b) If your EC2 instance doesn't have an IAM profile, obtain key/secret for AWS API. You'll need to write it in LocalSettings.php (see below).
7) Modify LocalSettings.php (see below).
Configuration in LocalSettings.php
If you do not specify credentials via $wgAWSCredentials, they are retrieved using the default credentials chain. This means they are obtained from IAM instance profile (if this EC2 instance has it) or from environmental variables AWS_ACCESS_KEY_ID
, AWS_SECRET_ACCESS_KEY
and AWS_SESSION_TOKEN
.
Needed IAM permissions
Replace <something>
with the name of your S3 bucket, e.g. wonderfulbali234
.
Custom S3 domain
You can use a domain name for images (for example, img.mysite.com
). This is needed when you want a CDN (such as CloudFlare) to cache your images. See [https://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html Virtual Hosting of Buckets] for details.
1) At your DNS provider, add a CNAME entry. For example, point img.mysite.com
to <your-wgAWSBucketName>.s3.<location>.amazonaws.com
).
2) In LocalSettings.php, set $wgAWSBucketDomain
. The following values are supported:
Migrating images
By default the extension stores all images in the top-level directory of the bucket.
If you are migrating an existing images
folder, MediaWiki uses a hashed directory structure. You will need to add this to your LocalSettings.php
for the image paths to be generated correctly.
If your images
folder previously was serving multiple wikis split into different subdirectories, you need to set $wgAWSBucketTopSubdirectory
. This setting is not recommended for new wikis.
Troubleshooting
My wiki uses Extension:MultimediaViewer (or shows images as popups), and now they don't work
If you have this issue, attach a CORS policy to your S3 bucket with images.
This will allow JavaScript (in this case, popup-showing script of Extension:MultimediaViewer) from the domain where your Wiki is hosted to download the images from Amazon S3 URL. For example, if the domain of your wiki is www.example.com
, you can use the following policy:
Local storage is still used, even though the extension is shown to be installed
This can happen if some settings are missing. Make sure you have at least $wgAWSBucketName
and $wgAWSRegion
are set.
I'm getting Exception, even though the extension is shown to be installed
This can happen if some settings are missing. Make sure that $wgAWSRegion
is set (even if your config doesn't use it, e.g. when using non-Amazon providers).
Non-standard configuration
Using another S3-compatible service (not Amazon S3 itself)
You can use non-Amazon software that supports S3 API (such as Apache CloudStack, Digital Ocean, etc.) instead of Amazon S3 itself. To enable this, add the following lines to LocalSettings.php:
Make sure $wgAWSBucketName
and $wgAWSRegion
are set as well.
Some software (such as MinIO) doesn't use subdomains for buckets, in which case you need the following configuration:
Some software doesn't support modern checksums (expected by AWS SDK v3.337.0 and above). You can workaround it by adding the following lines to LocalSettings.php: