Mediawiki/Installing/CentOS7

From r00tedvw.com wiki
Jump to: navigation, search

Installing | Multiple Instances | Ubuntu Installation | CentOS7 Installation

Contents

Overview

Installing Mediawiki 1.33 on CentOS7 as of 8/21/2019.

Requirements

Documented here.

  • Mediawiki 1.33
  • Apache httpd webserver
  • PHP 7.0.13
  • MariaDB

You will also want to make sure your Centos instance is accessible by hostname, either publishing a DNS A record or updating your local hosts file. This needs to be done as Apache HTTPD will parse the http request and look at the servername submitted by the browser. if you use the IP address, the server name in the http request will be the IP, not the hostname. Combine that with the HTTPD conf file with a servername entry as the Hostname, you can see the issue. NOTE: Yes, you can implement the ServerName in the httpd config as the IP address, however that is not what normal production servers do, so i generally avoid these practices.

Operating System Basics

Skip this if needed.

Create user

Create a new user, give them a home directory, and add them to the wheel group which by default in centos gives sudo access. After, change the password.

~$ useradd wikiuser -d /home/wikiuser -G wheel
~$ passwd wikiuser

Update system

~$ sudo yum upgrade -y

Install basic packages

~$ sudo yum install -y telnet net-tools vim tcpdump bind-utils redhat-lsb-core wget nfs-utils policycoreutils-python setroubleshoot setools 

For an explanation of each package, look at: Common Packages

PHP 7

So unfortunately PHP7+ is not available in the standard CentOS 7 repositories. This means you will either have to make it from source, or add another trusted repository you can grab it from, which is obviously much easier than making.
If you want to check what version of PHP is available to you from the repos, run this:

~$ sudo yum info php | egrep "Name|Version"
Name        : php
Version     : 5.4.16

As we can see above, only 5.4.16 is available to us.

Adding repositories

So lets add a couple of trusted repositories to get PHP7+

~$ sudo yum install -y epel-release yum-utils
~$ sudo yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
~$ sudo yum-config-manager --enable remi-php73

Install PHP 7+

Now with the repos taken care of, we can get the correct version of PHP

~$ sudo yum info php | egrep "Name|Version"
Name        : php
Version     : 7.3.8
~$ sudo yum install -y php

Apache

Super easy as its in the CentOS default repos. It may already be installed and up to date if you did an upgrade already.

~$ sudo yum install -y httpd

MariaDB

Again, super easy as its the CentOS default repos. Ive previously always used MySQL, but it doesn't look like mysql-server in available in the default CentOS repos anymore (at least not for 7). Not a huge deal, MariaDB I believe uses the same SQL syntax and is practically the same thing (being a fork and all), especially since it was created by the inventor of MySQL =P.

~$ sudo yum install -y mariadb-server

Mediawiki

Now that we've got all the dependencies taken care of, we can move on to mediawiki. I'm using the latest available version (at least at the time of this writing).

~$ wget https://releases.wikimedia.org/mediawiki/1.33/mediawiki-1.33.0.tar.gz

Since i'm going to setup Mediawiki as a subsite (not the root), we will create a directory before extracting the tarball.

~$ sudo mkdir -p /var/www/html/r00tedvw.local/wiki
~$ sudo tar -C /var/www/html/r00tedvw.local/wiki -zxf mediawiki-1.33.0.tar.gz --strip-components 1

=Configure MariaDB=
We need to setup a MariaDB then create a basic database and database user for mediawiki to use.
 <nowiki>~$ sudo systemctl start mariadb
~$ sudo systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
~$ sudo mysql_secure_installation
Set root password? [Y/n] y
Remove anonymous users? [Y/n] y
 Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y

Now we setup the USER, DB, and Permissions.

~$  sudo mysql -u root -p
MariaDB [(none)]> CREATE USER 'wiki'@'localhost' IDENTIFIED BY 'Password1';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> CREATE DATABASE wikidb;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON wikidb.* TO 'wiki'@'localhost' IDENTIFIED BY 'Password1' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> SHOW GRANTS FOR 'wiki'@'localhost';
+-------------------------------------------------------------------------------------------------------------+
| Grants for wiki@localhost                                                                                   |
+-------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'wiki'@'localhost' IDENTIFIED BY PASSWORD '*7EE969BBE0A3985C8BFF9FA65A06345C67FE434A' |
| GRANT ALL PRIVILEGES ON `wikidb`.* TO 'wiki'@'localhost' WITH GRANT OPTION                                  |
+-------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

MariaDB [(none)]> exit
Bye

Configure Apache

Very basic setup here, nothing fancy.

~$ sudo systemctl start httpd
~$ sudo systemctl enable httpd

You also may want to double check and make sure Apache is setup to look for site conf files in conf.d

~$ sudo grep "conf.d/*" /etc/httpd/conf/httpd.conf
# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf

Notice that IncludeOptional conf.d/*.conf is not commented out, so in our case we are good to go.
Now we can make the server conf file.

~$ sudo vim /etc/httpd/conf.d/r00tedvw.local.conf
add:
<VirtualHost *:80>
       ServerName r00tedvw.local
       ServerAdmin [email protected]
       DocumentRoot /var/www/html/r00tedvw.local
       TransferLog logs/r00tedvw.local-access_log
       ErrorLog logs/r00tedvw.local-error_log
</VirtualHost>

=Firewall=
Getting close now so lets open the firewall up. Let's start by finding the active zone.
 <nowiki>~$ sudo firewall-cmd --get-active-zone
public
  interfaces: ens160

and with that we can open the firewall up.

~$ sudo firewall-cmd --permanent --add-service=http
~$ sudo firewall-cmd --permanent --add-service=mysql
~$ sudo firewall-cmd --reload
~$ sudo firewall-cmd --zone=public --list-services
ssh dhcpv6-client http mysql

Configure Mediawiki

Don't get too excited, I can guarantee you we are missing dependencies, but lets fire it up and check out what we have so far.

~$ sudo systemctl restart httpd

Now in a browser, go to your mediawiki instance. In my case it was: http://r00tedvw.local/wiki
The first time you try, your browser may redirect you to their search engine because the domain doesn't actually exist, just try again, making sure to have http:// in front.

If you're lucky like I was, you'll be greeted with a message:

MediaWiki 1.33 internal error
Installing some PHP extensions is required.

Required components
You are missing a required extension to PHP that MediaWiki requires to run. Please install:

mbstring (more information)
xml (more information)

Soooo.... let's install them right quick.

~$ sudo yum install -y php-mbstring php-xml
~$ sudo systemctl restart httpd

Revisit your site and WOOT! you should see that its ready to setup, so click the link.

MediaWiki 1.33.0
LocalSettings.php not found.

Please set up the wiki first.

Choose your language, hit continue..... DOH, we have another dependency issue (at least I did).

Could not find a suitable database driver! You need to install a database driver for PHP. The following database types are supported: MariaDB, MySQL, or compatible, PostgreSQL, Oracle, Microsoft SQL Server, SQLite.

But... its an easy fix.

~$ sudo yum search php-mysql
...
php-mysql.x86_64 : A module for PHP applications that use MySQL databases
~$ sudo yum install -y php-mysql
~$ sudo systemctl restart httpd 

Let's check that config page again.

The environment has been checked. You can install MediaWiki.

Happy Dance!

LocalSettings.php

By going through the setup you are essentially creating a LocalSettings.php file. The GUI makes it easy.

Database type
MariaDB, MySQL, or compatible
MariaDB/MySQL settings
Database host: localhost
Database name (no hyphens): wikidb
Database username: wiki
Database password: Password1
Database settings
Database account for web access: [check] Use the same account as for installation
Storage engine: InnoDB (recommended)
Name
Name of wiki: Be Creative!
Project namespace: Same as the wiki name: Wiki
Administrator account
Your username: copycat
Password: pwned
Password again: pwned
Email address: Make this a real email address
Ask me more questions.
YES!
Options
User rights profile: Never choose Open Wiki. Either Account creation required if you want people to see the content, but not be able to edit without creating an account -OR- Private wiki if only those with account can even see the wiki.


The rest of it is getting deeper into configuration than this guide is meant to provide. Google the rest of the options if you're interested, otherwise you can leave them all with the defaults.

Open, Copy, & Restart

We are VERY close. When you completed the wiki configuration, it should have downloaded or provided the option to download a file called LocalSettings.php. Open that up in a text editor, copy the entire conents, and let's create a new file on our wiki server.

~$ sudo vim /var/www/html/r00tedvw.local/wiki/LocalSettings.php

Paste your clip board contents and save the file.

~$ sudo systemctl restart httpd

Visit your wiki again! It should work! Explore & have fun, I love using mediawiki as my own personal brain dump and hope you do too.

Personal tools
Namespaces

Variants
Actions
Navigation
Mediawiki
Confluence
DevOps Tools
Open Source Products
Ubuntu
Ubuntu 22
Mac OSX
Oracle Linux
AWS
Windows
OpenVPN
Grafana
InfluxDB2
TrueNas
MagicMirror
OwnCloud
Pivotal
osTicket
OTRS
phpBB
WordPress
VmWare ESXI 5.1
Crypto currencies
HTML
CSS
Python
Java Script
PHP
Raspberry Pi
Canvas LMS
Kaltura Media Server
Plex Media Server
MetaSploit
Zoneminder
ShinobiCE
Photoshop CS2
Fortinet
Uploaded
Certifications
General Info
Games
Meal Plans
NC Statutes
Politics
Volkswagen
Covid
NCDMV
Toolbox