In this article, we want to teach you How To Set up MediaWiki on Centos 7.
MediaWiki is the most powerful free open-source wiki software. This tutorial will show you to set up MediaWiki step by step on Centos 7 which includes:
- Install PHP Extention
- Set up MediaWiki
- Create MariaDB Database and User for MediaWiki
- Access MediaWiki Dashboard
Steps To Set up MediaWiki on Centos 7
To install MediaWiki on Centos 7, you need some requirements first.
You must log in to your server as a non-root user with sudo privileges. To do this, you can follow our article the Initial Server Setup with Centos 7.
Also, you need to have a LAMP stack installed on your server. To do this, you can check our article How to install the LAMP stack on Centos 7.
Step 1 – Install PHP Extensions For MediaWiki
At this point, you need to install some PHP extensions for MediaWiki
Note: You Must have PHP 7.3 or higher version installed on your server. You can install PHP 7.3 on your server by following this article about How To Install PHP 7.3 on Centos 7.
Now use the command below to install the PHP extensions on Centos 7:
sudo yum install php-xml php-intl php-gd php-mbstring -y
Then, restart Apache to apply the changes on Centos 7 with the following command:
sudo systemctl restart httpd.service
Step 2 – Download MediaWiki on Centos 7
At this point, you need to visit the MediaWiki Downloads Page to get the latest LTS version of MediaWiki.
Then, use the following curl command to download MediaWiki:
curl -O https://releases.wikimedia.org/mediawiki/1.35/mediawiki-1.35.4.tar.gz
Now use the following command to extract your downloaded file:
tar xvzf mediawiki-*.tar.gz
Here you need to move the MediaWiki file to the /var/www/ directory with the command below:
sudo mv mediawiki-1.35.4/* /var/www/html
Step 3 – Create MariaDB Database User For MediaWiki
At this point, you need to create a MySQL database user for your MediaWiki on Centos 7. To do this, follow the steps below:
First, log in to your MariaDB shell with the following command:
mysql -u root -p
Now run the following command from your MariaDB shell to create your database:
MariaDB [(none)]> CREATE DATABASE my_wiki;
Next, create a new database user with the command below:
MariaDB [(none)]> GRANT INDEX, CREATE, SELECT, INSERT, UPDATE, DELETE, ALTER, LOCK TABLES ON my_wiki.* TO 'orca'@'localhost' IDENTIFIED BY 'password';
Flush the privileges and exit from your MariaDB shell by running the commands below:
MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> exit;
Step 4 – Access MediaWiki Dashboard on Centos 7
At this point, you can access the MediaWiki web interface by typing your server’s IP address on your web browser:
On the first screen, select set up the Wiki.
Then, you need to select your desired language and click continue.
On the next page, you should see the green message that says: The environment has been checked. You can install MediaWiki. Click Continue.
Now you will see the MySQL settings for MediaWiki on Centos 7. Provide your MySQL credentials and click Continue.
Next, keep everything by default and click Continue.
Then, you should provide your MediaWiki details info.
Finally, you can leave settings by default. Also, if you have installed XCache before, you will need to check that to enable it.
When you are done you will see:
To complete your MediaWiki installation on Centos 7, you will need to move a file called LocalSettings.php to your server. You should download this file before you close the above window.
Now, you need to upload the file to /var/www/html. To do this, first, open the file on your Centos 7 with your favorite text editor, here we use vi:
sudo vi /var/www/html/LocalSettings.php
Then, open the file on your computer and copy the contents into your SSH window. After you have saved the file, you can click enter your wiki on the MediaWiki installation window and your wiki should be ready to use.
At this point, you have learned to set up and configure MediaWiki on Centos 7. As you can see MediaWiki is the most powerful software to manage your wikis.
Hope you enjoy it. You may be interested in these articles too: