Skip to content

Instantly share code, notes, and snippets.

@rcguy
Last active Aug 29, 2015
Embed
What would you like to do?
Non-Interactive Script that installs MediaWiki, LAMP, and sets up the MySQL Database on Ubuntu 14.10
#!/bin/bash
# Installs MediaWiki, LAMP, and setup the MySQL Database on Ubuntu 14.10
# Tested on: Ubuntu Server 14.10 - x64 / 2 Cores / 2GB RAM / 20 GB SSD / VPS
# ==> USER VARIABLES <==
MYSQL_ROOT_PASSWORD="root"
DB_NAME="mediawiki"
DB_USER="mediawiki"
DB_USER_PASSWORD="mediawiki"
# ==> MAIN PROGRAM <==
set -e
# pre-seed mysql root password
echo "mysql-server-5.5 mysql-server/root_password password $MYSQL_ROOT_PASSWORD" | sudo debconf-set-selections
echo "mysql-server-5.5 mysql-server/root_password_again password $MYSQL_ROOT_PASSWORD" | sudo debconf-set-selections
# system prep
apt-get update
apt-get -y upgrade
apt-get -y autoremove
apt-get -y autoclean
apt-get install -y apache2 libapache2-mod-php5 libapache2-mod-auth-mysql mysql-server mysql-client php5 php5-mysql php5-cli php5-intl php5-mcrypt php5-gd
# create database and user for mediawiki
MYSQL=`which mysql`
Q1="CREATE DATABASE IF NOT EXISTS $DB_NAME;"
Q2="GRANT ALL PRIVILEGES ON $DB_NAME.* TO '$DB_USER'@'localhost' IDENTIFIED BY '$DB_USER_PASSWORD';"
Q3="FLUSH PRIVILEGES;"
SQL="${Q1}${Q2}${Q3}"
$MYSQL -uroot -p$MYSQL_ROOT_PASSWORD -e "$SQL"
# install MediaWiki
wget http://releases.wikimedia.org/mediawiki/1.24/mediawiki-1.24.1.tar.gz
tar -xvzf mediawiki-*.tar.gz
mkdir -p /var/www/html/mediawiki
cp -R mediawiki-*/* /var/www/html/mediawiki
rm -rf mediawiki-*/* mediawiki-*.tar.gz
# finish
service apache2 restart
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment