This document shows you how to install MediaWiki on Ubuntu 14.10 and run your own wiki site. MediaWiki is free opensource software written in PHP that was original intended for Wikipedia. It now runs on many other non-profit and wiki sites across the Internet.
If you wish to run a wiki site that looks similar to Wikipedia, then install MediaWiki on your server. MediaWiki requires the opensource LAMP stack to function. You must install Apache2 or similar webserver, MySQL or MariaDB and PHP. This tutorial is going to show you how to get them installed and configured.
- Installing the LAMP Stack
There LAMP stack is a short referenced name for Linux, Apache2, MySQL and PHP. You can replace Apache2 with another webserver like Nginx and MySQL with MariaDB. For this tutorial, we’ll install the original LAMP stack.
To install the LAMP stack on Ubuntu, run the commands below:
sudo apt-get -y install apache2 mysql-server mysql-client php5 php5-mysql php5-gd imagemagick unzip
You may have to install other PHP extensions to enhance MediaWiki performance and security. But the basic requirements to run MediaWiki are met in the above commands.
During the installation, you may get a prompt to create a new MySQL root password. Create and confirm one.
While not mandatory, it is highly recommended that you set a password for the MySQL administrative “root” user.
If this field is left blank, the password will not be changed.
New password for the MySQL “root” user:
After install the LAMP stack, the next thing is to configure MediaWiki database. MediaWiki uses database to store data and content. Run the commands below to secure your database installation.
sudo mysql_secure_installation
When prompted, follow the guide below.
Next, choose Yes for the rest of the prompts until you’re done.
- Enter current password for root (enter for none): Type root password
- Change the root password? N
- Remove anonymous users? Y
- Disallow root login remotely? Y
- Remove test database and access to it? Y
- Reload privilege tables now? Y
To sign on to the database run the commands below
mysql -u root -p
Then run the SQL statement below to create a new database MediaWiki database.
CREATE DATABASE mediawikidb;
Next run the commands below to create MediaWiki database user account and password
CREATE USER mediawikiuser@localhost IDENTIFIED BY 'mediawikiuser_password_here';
Finally run the commands below to give the user access the database
GRANT ALL ON mediawikidb.* TO mediawikiuser@localhost;
Flush and exit the database.
Now that the database and packages are installed, go and download MediaWiki package from online. Use the commands below to download the latest version as of this date.
cd /tmp/ && wget http://releases.wikimedia.org/mediawiki/1.24/mediawiki-1.24.1.tar.gz
Next, run the commands below to extract the downloaded file.
tar xvzf mediawiki-*.tar.gz
Backup the default Apache root directory
sudo mv /var/www/html/* ~/
Then move MediaWiki files and folders to your Apache2 default repository.
sudo mv mediawiki-1.24.1/* /var/www/html
Next, give Apache2 ownership of the directory
sudo chown -R www-data:www-data /var/www/html/
Restart Apache2 server
sudo service apache2 restart
Finally, open your browser and browse to the server using its hostname or IP address (http://Server-IP_address)
At first, you’ll get an error MediaWiki 1.24.1 LocalSettings.php not found. Click the link below the error to setup to first configure MediaWiki. On the first, page, you’ll want to choose your language settings and continue.
MediaWiki installer will check and verify your environment. If any package is missing, you may go back and install it and continue with the setup.
On the database setup page, enter hostname, database and username and the user password. Then click Continue
The default settings should be good. Continue with the installation.
At the end of the installation, a file called LocalSettings.php should automatically begin to download. This file needs to be saved in the root directory of your webserver (where MediaWiki) content are.
Open the file and copy its content and paste it in here
vi /var/www/html/LocalSettings.php
After that, click the link to go to your Wiki page to complete the installation
That’s it! This is how you install MediaWiki on Ubuntu 14.10.
Enjoy!