How to Set Up a MediaWiki 1.23 Server on CentOS 6

From steamWiki
Jump to: navigation, search

This how to covers installing MediaWiki 1.23.1 on a CentOS6 server.

  1. Installing MediaWiki
    1. Install Apache
      1. run sudo yum install httpd to install apache and its dependencies
      2. run sudo chkconfig httpd on to make sure apache starts on boot
      3. Add the following lines to your /etc/sysconfig/iptables file to allow web traffic
        • # Accept web traffic.
        • -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
      4. restart to ensure the iptables are reloaded and check that apache is correctly started at boot
      5. Visit the ip address of your server, preferably from a different computer, to ensure everything is working properly. You should see something like this.
        • Apache 2 Test.png
    2. Install MySQL
      1. run sudo yum install mysql-server to install the mysql server and its dependencies
      2. run sudo chkconfig mysqld on to make sure that mysql starts on boot
      3. run sudo service mysqld start to start the mysql server
      4. run sudo mysql_secure_installation
        1. just hit enter for 'none' at the 1st password prompt
        2. hit y and enter to set a root password
        3. type in your new root-password and hit enter (twice)
        4. hit y and enter to remove the anonymous account
        5. hit y and enter to ensure that root can only login at the physical keyboard
        6. hit y and enter to remove the test database
        7. hit y and enter to reload the privilege table
        8. run mysql -u root -p to log into MySQL monitor
          1. run CREATE USER 'wiki'@'localhost' IDENTIFIED BY '<Your_Secure_Password>'; to create the wiki user
          2. run CREATE DATABASE wikidb; to create the wiki database
          3. run GRANT ALL PRIVILEGES ON wikidb.* TO 'wiki'@'localhost' IDENTIFIED BY '<Your_Secure_Password>' WITH GRANT OPTION; to give the wiki user correct access to wikidb
    3. Install PHP
      1. run sudo yum install php php-mysql php-gd php-xml to install required php components dependencies
      2. run sudo vi /var/www/html/info.php to create and edit a new webpage & populate the file with the following:
        • <?php
        • phpinfo();
        • ?>
      3. save & exit
      4. run sudo service httpd restart to reload the apache server
      5. visit your server ip/info.php (ie: http://192.168.1.100/info.php) and it should look something like this:
        • PHP 5 Test.png
    4. Install Mediawiki
      1. If you don't already have it, install wget via sudo yum install wget
      2. Visit the MediaWiki Download page to find the latest version. Substitute the path to the latest version in the next command if necessary
      3. run cd ~ to navigate to your home directory
      4. run wget https://releases.wikimedia.org/mediawiki/1.23/mediawiki-1.23.1.tar.gz to download the latest version of MediaWiki
      5. run tar xvzf mediawiki-1.23.1.tar.gz to unpack the downloaded file
      6. run sudo mv ~/mediawiki-1.23.1 /etc/mediawiki to move the mediawiki directory to a non-version specific general location
      7. run sudo ln -s /etc/mediawiki/ /var/www/ to create a symbolic link from Apache's document root to the MediaWiki directory
      8. run sudo chown -h apache:apache /var/www/mediawiki to ensure that the symbolic link is owned by the apache user
      9. run sudo chown -R apache:apache /var/www/mediawiki/ to make the apache user the owner of all of the mediawiki files so that can properly serve the documents
      10. Configure SELinux to allow the change in apache's DocumentRoot
        1. run sudo yum install policycoreutils-python to allow you to run setsebool (this can take several minutes)
        2. run setsebool -P httpd_enable_homedirs on to allow apache to use a non-standard DocumentRoot (this can take several minutes)
      11. Backup and modify /etc/httpd/conf/httpd.conf
        1. change DocumentRoot "/var/www/html" to DocumentRoot "/var/www/mediawiki"
        2. change <Directory "/var/www/html"> to <Directory "/var/www/mediawiki">
        3. change DirectoryIndex index.html index.html.var to DirectoryIndex index.html index.html.var index.php
      12. run sudo service httpd restart to restart apache using the new configuration
      13. at this point you should be able to visit your server again and see something like this
        • MediaWiki Test.png
      14. click the set up the wiki link and follow the instructions. My server was configured as below:
        1. Language
          1. Your language: en - English
          2. Wiki language: en - English
        2. Existing wiki
        3. Welcome to MediaWiki
        4. Connect to database
          1. Database type: MySQL
          2. Database host: localhost
          3. Database name: wikidb
          4. Database table prefix:
          5. Database username: wiki
          6. Database password: Your_Secure_Password
        5. Database settings
          1. Use the same account as for installation: yes
          2. Storage engine: InnoDB
          3. Database character set: UTF-8 (I went with UTF-8 since my wiki will only really use English)
        6. Name
          1. Name of wiki: steamwiki
          2. Project namespace: Same as the wiki name: Steamwiki
          3. Your username: sean
          4. Password: Super_Secret_Password
          5. Password again: Super_Secret_Password
          6. Email address: sean@gmail.com
          7. Subscribe to the release announcements mailing list: no
          8. Ask me more questions: yes
        7. Options
          1. User rights profile: Authorized editors only (I chose this because my wiki is a place for me to post articles. You may want a more relaxed wiki for your project)
          2. Copyright and license: Creative Commons Attribution Share Alike (you may want to review the options for your own wiki)
          3. Enable outbound email: no (I don't need email for my wiki)
          4. Extensions: PdfHandler, WikiEditor (You may want other extensions)
          5. Enable file uploads: yes
          6. Directory for deleted files: /etc/mediawiki/images/deleted
          7. Logo URL: $wgStylePath/common/images/wiki.png (you can change this later in LocalSettings.php)
          8. Settings for object caching: No caching (no functionality is removed, but speed may be impacted on larger wiki sites)
        8. Install
      15. After the install is complete you should see a screen like the one below and be able to download the LocalSettings.php file you just downloaded.
        • MediaWiki Complete.png
      16. Move LocalSettings.php into /etc/mediawiki on your server
      17. Be sure to run sudo chown apache:apache LocalSettings.php so that the web server can access the file

References