How To Install MediaWiki on Centos 6.4

Published on November 13, 2013

Adam LaGreca

How To Install MediaWiki on Centos 6.4
Not using CentOS 6?Choose a different version or distribution.
CentOS 6

Status: Deprecated

This article covers a version of CentOS that is no longer supported. If you are currently operating a server running CentOS 6, we highly recommend upgrading or migrating to a supported version of CentOS.

Reason: CentOS 6 reached end of life (EOL) on November 30th, 2020 and no longer receives security patches or updates. For this reason, this guide is no longer maintained.

See Instead: This guide might still be useful as a reference, but may not work on other CentOS releases. If available, we strongly recommend using a guide written for the version of CentOS you are using.

The following DigitalOcean tutorial may be of immediate interest, as it outlines installing MediaWiki on a CentOS 7 server:


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: <a href=“https://www.digitalocean.com/community/articles/how-to-install-linux-apache-mysql-php-lamp-stack-on-centos-6”>CentOS LAMP Installation Tutorial</a>. <br/><br/>

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).

<ul> <li>Go to MediaWiki’s official website and download the latest version of the platform:</li> <pre>wget http://download.wikimedia.org/mediawiki/1.21/mediawiki-1.21.2.tar.gz</pre> <li>After the download completes untar the package:</li> <pre>tar xvzf mediawiki-*.tar.gz</pre> <li>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:</li> <pre>sudo mv mediawiki-1.21.2 /etc/mediawiki</pre> <li>Create a symbolic link between the MediaWiki directory and Apache’s document root:</li> <pre>sudo ln -s /etc/mediawiki/ /var/www/html</pre> <li>Restart Apache</li> <pre>sudo service apache2 restart</pre> </ul>

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:

<ul> <li>Log into MySQL</li>

<pre>mysql -u root -p</pre>

<li>Create a Dedicated Database</li><br/> You can name your DB whatever you’d like-- here it will be example_wiki.

<pre>create database example_wiki;</pre>

<li>Grant Permissions</li><br/> Next you will provide a user for the new database with the permissions that MediaWiki requires. Replace “wikiuser” and “password” with your own specifications.

<pre>grant index, create, select, insert, update, delete, alter, lock tables on my_wiki.* to ‘wikiuser’@‘localhost’ identified by ‘password’;</pre>

<li>Finishing Up</li><br/> Implement changes and quit MySQL.

<pre>FLUSH PRIVILEGES; exit;</pre> </ul>

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!”

<img src=“https://assets.digitalocean.com/articles/mediawiki_centos/img1.png” />

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!

<div class=“author”>By Adam LaGreca</div>

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors
Default avatar
Adam LaGreca


Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

If this is CentOS then

service apache2 restart

apache2: unrecognized service

Should be:

service httpd restart

Stopping httpd: [ OK ] Starting httpd: [ OK ]


When I go to [domain]/mediawiki/index.php I get:

Forbidden You don’t have permission to access /mediawiki/index.php on this server.

Great article.

I added Alternative PHP Cache to my setup which you can select during the MediaWiki install.

Commands: yum install php-pear php-devel httpd-devel pcre-devel gcc make pecl install apc

Watch the end of the install for the line to to add to php.ini.

and for CentOS it is - service httpd restart


Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel