We hope you find this tutorial helpful. In addition to guides like this one, we provide simple cloud infrastructure for developers. Learn more →

How To Install MediaWiki on Centos 6.4

PostedNovember 13, 2013 24k views CentOS

Mediawiki


MediaWiki is a free open source wiki program that allows users to create their own personal wiki sites. Originally built for Wikpedia, it is now used by thousands of other projects due to its scalability and high customization.

Before working with MediaWiki, you need to have LAMP installed on your server. If you don't have the Linux, Apache, MySQL, PHP stack on your server, you can find the tutorial for setting it up here: CentOS LAMP Installation Tutorial.

Install MediaWiki on your VPS


At the time of writing, the latest version of MediaWiki is MediaWiki 1.21.2. To check for the latest version of the platform, visit their website and simply alter the code to match the most updated version (if desirable).

  • Go to MediaWiki’s official website and download the latest version of the platform:
wget http://download.wikimedia.org/mediawiki/1.21/mediawiki-1.21.2.tar.gz
  • After the download completes untar the package:
  • tar xvzf mediawiki-*.tar.gz
  • The default directory for the downloaded contents includes the specified version of the platform-- it may be best to move the contents to a more convenient location:
  • sudo mv mediawiki-1.21.2 /etc/mediawiki
  • Create a symbolic link between the MediaWiki directory and Apache’s document root:
  • sudo ln -s /etc/mediawiki/ /var/www/html
  • Restart Apache
  • sudo service apache2 restart

    Create a MySQL Database and User


    Creating a MySQL database is simple and increases security, as it eliminates the need for sharing the MySQL root information. Follow these steps:

    • Log into MySQL
    mysql -u root -p
  • Create a Dedicated Database

  • You can name your DB whatever you'd like-- here it will be **example_wiki**.
    create database example_wiki;
  • Grant Permissions

  • Next you will provide a user for the new database with the permissions that MediaWiki requires. Replace "wikiuser" and "password" with your own specifications.
    grant index, create, select, insert, update, delete, alter, lock tables on my_wiki.* to 'wikiuser'@'localhost' identified by 'password';
  • Finishing Up

  • Implement changes and quit MySQL.
    FLUSH PRIVILEGES;
    exit;

    Visit: [domain]/mediawiki/index.php.

    Set Up MediaWiki


    MediaWiki will now be configured through your browser's on-screen instructions.

    When you reach the “MySQL settings” section of the setup page, leave the Database Host as localhost; enter in the MySQL database name, username, and password which you setup in the previous steps.

    Press continue until you reach the page that says, “Complete!”

    Once the LocalSettings.php file finishes downloading, upload it to /etc/mediawiki or whichever directory contains MediaWiki’s “index.php” file on your VPS.

    You can copy the LocalSettings.php file from your computer to the server with SCP (Secure Copy):

    scp /path/to/LocalSettings.php [username]@[IP Address]:/etc/mediawiki
    

    After the file is uploaded, you will be able to access your personal wiki at [domain]/mediawiki!

    By Adam LaGreca

    3 Comments

    Creative Commons License