Skip to content

Instantly share code, notes, and snippets.

@thisismattmiller
Last active May 18, 2020 20:03
Show Gist options
  • Select an option

  • Save thisismattmiller/44af3ee3f8143a80b443f5e38e0a44d0 to your computer and use it in GitHub Desktop.

Select an option

Save thisismattmiller/44af3ee3f8143a80b443f5e38e0a44d0 to your computer and use it in GitHub Desktop.
Wikibase Install May 2020

Lanuch AWS Instance. I'm using a t3.large with 50GB disk drive using the Linux AMI 2 OS. Make sure you have public DNS turned on (https://stackoverflow.com/questions/20941704/ec2-instance-has-no-public-dns)

SSH to the instance

ssh -i ~/.ssh/YOURKEY.pem ec2-user@[YOUR PUBLIC DNS]

Update system

sudo yum update

Install docker, docker compose

sudo amazon-linux-extras install docker
sudo service docker start
sudo usermod -a -G docker ec2-user
sudo chkconfig docker on
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo reboot

Add ports 80, 8282 and 9191 to your AWS aloowed ports

Download the docker-compose YML file (this one is modified to help you, get the orginal from the wikibase docker git repo)

wget https://gist.githubusercontent.com/thisismattmiller/44af3ee3f8143a80b443f5e38e0a44d0/raw/f1688ebc20c81df055892f8fd263d4e57cf466df/docker-compose.yml
nano docker-compose.yml

Go through and make changes to where there are [BRACKETS] for your info, mostly DNS hostname

docker-compose up

Will take a few min.

Try loading your site at your AWS Public Hostname address, like "ec2-54-166-137-158.compute-1.amazonaws.com"

Try to log in to the admin account, goto [YourDNSHostName]:9191 to setup the quick statements

Try creating a new property, add statments, text out port :8282 to make sure the query service works.

Open a new ssh connection, we are going to get the LocalSettings.php file from the container and modify it.

type:

docker ps

To get a list of all the running containers, look for the alphanumeric ID for the container "wikibase/wikibase:1.34-bundle" would look something like "d26ae1241260"

Run

docker cp CONTAINERID:/var/www/html/LocalSettings.php  ./LocalSettings.php

Now you can modify the LocalSettings.php to disable account creation and anon editing by aadding these to it:

$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['createaccount'] = false;

You can also customize the logo with a new image, by adding an image to replace it:

wget https://thisismattmiller.s3.amazonaws.com/ld4p.png

Edit the docker-compose.yml file to enable these new files to overwrite the ones in the container: in the file:

      - ./LocalSettings.php:/var/www/html/LocalSettings.php
      - ./ld4p.png:/var/www/html/resources/assets/wiki.png

Control-C to stop the running service in the other connection. And restart it

docker-compose up -d

To run it in the background


If you ever mess up or need to change the URL or something else like that you can wipe out the current data with

docker rm $(docker ps -a -f status=exited -q)
docker volume rm $(docker volume ls -qf dangling=true)

This will remove all data.

# Wikibase with Query Service
#
# This docker-compose example can be used to pull the images from docker hub.
#
# Examples:
#
# Access Wikibase via "http://localhost:8181"
# (or "http://$(docker-machine ip):8181" if using docker-machine)
#
# Access Query Service via "http://localhost:8282"
# (or "http://$(docker-machine ip):8282" if using docker-machine)
version: '3'
services:
wikibase:
image: wikibase/wikibase:1.34-bundle
links:
- mysql
ports:
# CONFIG - Change the 8181 here to expose Wikibase & MediaWiki on a different port
- "80:80"
volumes:
- mediawiki-images-data:/var/www/html/images
- quickstatements-data:/quickstatements/data
# - ./LocalSettings.php:/var/www/html/LocalSettings.php
# - ./custom.png:/var/www/html/resources/assets/wiki.png
depends_on:
- mysql
- elasticsearch
restart: unless-stopped
networks:
default:
aliases:
- wikibase.svc
- [YOUR AWS HOSTNAME]
# CONFIG - Add your real wikibase hostname here, for example wikibase-registry.wmflabs.org
environment:
- DB_SERVER=mysql.svc:3306
- MW_ELASTIC_HOST=elasticsearch.svc
- MW_ELASTIC_PORT=9200
# CONFIG - Change the default values below
- MW_ADMIN_NAME=WikibaseAdmin
- MW_ADMIN_PASS=[CHANGE PASSWORD]
- MW_ADMIN_EMAIL=admin@example.com
- MW_WG_SECRET_KEY=secretkey
# CONFIG - Change the default values below (should match mysql values in this file)
- DB_USER=wikiuser
- DB_PASS=sqlpass
- DB_NAME=my_wiki
- QS_PUBLIC_SCHEME_HOST_AND_PORT=http://[YOUR AWS HOSTNAME]:9191
mysql:
image: mariadb:10.3
restart: unless-stopped
volumes:
- mediawiki-mysql-data:/var/lib/mysql
environment:
MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
# CONFIG - Change the default values below (should match values passed to wikibase)
MYSQL_DATABASE: 'my_wiki'
MYSQL_USER: 'wikiuser'
MYSQL_PASSWORD: 'sqlpass'
networks:
default:
aliases:
- mysql.svc
wdqs-frontend:
image: wikibase/wdqs-frontend:latest
restart: unless-stopped
ports:
# CONFIG - Change the 8282 here to expose the Query Service UI on a different port
- "8282:80"
depends_on:
- wdqs-proxy
networks:
default:
aliases:
- wdqs-frontend.svc
environment:
- WIKIBASE_HOST=wikibase.svc
- WDQS_HOST=wdqs-proxy.svc
wdqs:
image: wikibase/wdqs:0.3.10
restart: unless-stopped
volumes:
- query-service-data:/wdqs/data
command: /runBlazegraph.sh
networks:
default:
aliases:
- wdqs.svc
environment:
- WIKIBASE_HOST=[YOUR AWS HOSTNAME]
- WDQS_HOST=wdqs.svc
- WDQS_PORT=9999
expose:
- 9999
wdqs-proxy:
image: wikibase/wdqs-proxy
restart: unless-stopped
environment:
- PROXY_PASS_HOST=wdqs.svc:9999
ports:
- "8989:80"
depends_on:
- wdqs
networks:
default:
aliases:
- wdqs-proxy.svc
wdqs-updater:
image: wikibase/wdqs:0.3.10
restart: unless-stopped
command: /runUpdate.sh
depends_on:
- wdqs
- wikibase
networks:
default:
aliases:
- wdqs-updater.svc
environment:
- WIKIBASE_HOST=[YOUR AWS HOSTNAME]
- WDQS_HOST=wdqs.svc
- WDQS_PORT=9999
elasticsearch:
image: wikibase/elasticsearch:6.5.4-extra
restart: unless-stopped
networks:
default:
aliases:
- elasticsearch.svc
environment:
discovery.type: single-node
ES_JAVA_OPTS: "-Xms512m -Xmx512m"
# CONFING, in order to not load quickstatements then remove this entire section
quickstatements:
image: wikibase/quickstatements:latest
ports:
- "9191:80"
depends_on:
- wikibase
volumes:
- quickstatements-data:/quickstatements/data
networks:
default:
aliases:
- quickstatements.svc
environment:
- QS_PUBLIC_SCHEME_HOST_AND_PORT=http://[YOUR AWS HOST]:9191
- WB_PUBLIC_SCHEME_HOST_AND_PORT=http://[YOUR AWS HOST]
- WIKIBASE_SCHEME_AND_HOST=http://[YOUR AWS HOST]
- WB_PROPERTY_NAMESPACE=122
- "WB_PROPERTY_PREFIX=Property:"
- WB_ITEM_NAMESPACE=120
- "WB_ITEM_PREFIX=Item:"
volumes:
mediawiki-mysql-data:
mediawiki-images-data:
query-service-data:
quickstatements-data:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment