Page MenuHomePhabricator
Paste P4838

Easy install mediawiki on labs!
ActivePublic

Authored by Addshore on Jan 30 2017, 11:02 PM.
Tags
None
Referenced Files
F31063220: raw.txt
Nov 12 2019, 4:58 PM
F31063216: raw.txt
Nov 12 2019, 4:55 PM
F31063211: raw.txt
Nov 12 2019, 4:52 PM
F7043357: Easy install mediawiki on labs!
Mar 28 2017, 12:56 AM
F5440329: Easy install mediawiki on labs!
Feb 1 2017, 9:28 AM
F5423430: Easy install mediawiki on labs!
Jan 30 2017, 11:02 PM
Can be done across 1 or more instance.
#### DB
sudo apt install mariadb-server
sudo sed -i -e 's/bind-address/#bind-address/g' /etc/mysql/my.cnf
sudo systemctl restart mysql
#### WEB
# Install stuff
sudo apt install apache2 php7.3 php7.3-cli php7.3-mysql php7.3-intl php7.3-dom php7.3-mbstring php7.3-xml php7.3-zip php-apcu unzip
# Restart apache2 (Not sure why this is needed)
sudo systemctl restart apache2
# Cleanup the web dir
cd /var/www/html
sudo rm index.html
sudo chown :wikidev .
sudo chmod g+u .
umask g+rwx
# Setup mediawiki
git clone https://gerrit.wikimedia.org/r/mediawiki/core .
# The next 4 lines can be updated from https://getcomposer.org/download/
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
php composer.phar install
# Install mediawiki (TODO substitute vars)
sudo mysql -u root <<< "CREATE DATABASE DBNAME; GRANT ALL ON my_wiki.* TO 'DBUSER'@'localhost' IDENTIFIED BY 'DBPASS';"
php maintenance/install.php --dbuser DBUSER --dbpass DBPASS --dbname DBNAME --dbserver DBSERVER --lang LANGUAGECODE --pass ADMINPASS SITENAME ADMINUSER
# Configure mediawiki
sed -i '/wgScriptPath/ s|"/wiki"|""|' LocalSettings.php
sed -i '/wgServer/ s|"http://localhost"|"https://INSTANCE-PROXY.wmflabs.org"|' LocalSettings.php
cat >> LocalSettings.php << 'EOF'
$wgUsePrivateIPs = true;
$wgCdnServers = [
'172.16.0.164', # proxy-01.project-proxy.eqiad.wmflabs
'172.16.0.165', # proxy-02.project-proxy.eqiad.wmflabs
];
EOF
echo "error_reporting( -1 );" >> LocalSettings.php
echo "ini_set( 'display_errors', 1 );" >> LocalSettings.php
echo "\$wgShowExceptionDetails = true;" >> LocalSettings.php
echo "\$wgShowSQLErrors = true;" >> LocalSettings.php
echo "\$wgDebugDumpSql = true;" >> LocalSettings.php
echo "\$wgShowDBErrorBacktrace = true;" >> LocalSettings.php
# Clone extra stuff
git clone https://gerrit.wikimedia.org/r/mediawiki/skins/Vector ./skins/Vector
echo "wfLoadSkin( 'Vector' );" >> LocalSettings.php
# Update
php ./maintenance/update.php --quick

Event Timeline

"-dbserver" has one dash, that actually wasted one hour of mine :(((

"-dbserver" has one dash, that actually wasted one hour of mine :(((

Sorry! :/ thanks for spotting!

Pasting db setup here to make it easier to find:

sudo apt-get install mariadb-server
sudo sed -i -e 's/bind-address/#bind-address/g' /etc/mysql/my.cnf
sudo service mysql restart

Two remarks, from when I used this script to install the new wikidata-constraints wiki on labs (woo!):

  1. On line 12, mysql-client was not installed because it conflicted with mariadb-server-10.0. I first tried removing mariadb-server because I didn’t know what it was, which was a stupid solution; the correct solution, I think, is to remove mysql-client from the package list. mariadb-client-core-10.0, which is pulled in by mariadb-server, provides a /usr/bin/mysql, but apparently does not provide a mysql-client package that apt is aware of.
  2. I had to change $wgScriptPath from "/wiki" to "" in LocalSettings.php, since line 23 clones MediaWiki directly into the Apache DocumentRoot, not into wiki/. ("/" as $wgScriptPath does not work, by the way.)

Apart from those minor issues, this worked pretty well, so thanks for putting this document together!

One more small goodie for LocalSettings.php:

$wgUsePrivateIPs = true;
$wgSquidServers = [ 'IP HERE' ];

Without that, all anonymous edits will be credited to the proxy’s IP (not sure if that’s public, so I replaced it with IP HERE above).