Page MenuHomePhabricator
Paste P4838

Easy install mediawiki on labs!

Authored by Addshore on 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 .
# The next 4 lines can be updated from
php -r "copy('', '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"|""|' LocalSettings.php
cat >> LocalSettings.php << 'EOF'
$wgUsePrivateIPs = true;
$wgCdnServers = [
'', # proxy-01.project-proxy.eqiad.wmflabs
'', # proxy-02.project-proxy.eqiad.wmflabs
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 ./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).