Difference between revisions of "Creating And Configuring MediaWiki"
| (11 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
== Prerequisites == | == Prerequisites == | ||
| − | A server with the LAMP stack is required to run MediaWiki, a Wiki on how to accomplish that can be found [ | + | A server with the LAMP stack is required to run MediaWiki, a Wiki on how to accomplish that can be found [[Installing_The_LAMP_Stack_On_A_Server|here.]] If the server to be used already has the LAMP stack installed and running, this Prerequisites section can be skipped. |
| − | |||
== Installing The Correct Packages For PHP == | == Installing The Correct Packages For PHP == | ||
As of writing, MediaWiki requires PHP 7.3.19-24, 7.4.3, or later and will need to be installed manually. | As of writing, MediaWiki requires PHP 7.3.19-24, 7.4.3, or later and will need to be installed manually. | ||
<nowiki>sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm | <nowiki>sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm | ||
| − | + | sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm</nowiki> | |
<nowiki>sudo dnf module reset php | <nowiki>sudo dnf module reset php | ||
| − | + | sudo dnf module install php:remi-8.0 </nowiki> | |
Install the module to support the use of MariaDB: | Install the module to support the use of MariaDB: | ||
| − | <nowiki>sudo dnf install php-mysqlnd</nowiki> | + | <nowiki>sudo dnf install php-mysqlnd </nowiki> |
This may already be installed on the server, if so you can move on to the next step without issue. | This may already be installed on the server, if so you can move on to the next step without issue. | ||
Restart the Apache httpd.service for the changes to take effect: | Restart the Apache httpd.service for the changes to take effect: | ||
| − | <nowiki>sudo systemctl restart httpd.service</nowiki> | + | <nowiki>sudo systemctl restart httpd.service </nowiki> |
| − | |||
== Creating A Database for MediaWiki == | == Creating A Database for MediaWiki == | ||
| Line 42: | Line 40: | ||
The latest release of MediaWiki can be downloaded manually from [https://www.mediawiki.org/wiki/Download here (MediaWiki Downloads Page)], the latest release with the .tar.gz extension is the desired option for this tutorial. | The latest release of MediaWiki can be downloaded manually from [https://www.mediawiki.org/wiki/Download here (MediaWiki Downloads Page)], the latest release with the .tar.gz extension is the desired option for this tutorial. | ||
| − | <strong>mediawiki-VERSION will be used as a placeholder name for the mediawiki files, replace VERSION with the latest | + | <strong>mediawiki-VERSION will be used as a placeholder name for the mediawiki files, replace VERSION with the latest version that is being downloaded in the following commands.</strong> |
This release can also be downloaded from the command line on the remote server via the 'wget' tool: | This release can also be downloaded from the command line on the remote server via the 'wget' tool: | ||
| Line 64: | Line 62: | ||
In this case, 'wiki' will be included in all URLs for this Wiki, i.e.: | In this case, 'wiki' will be included in all URLs for this Wiki, i.e.: | ||
<nowiki> http://www.example.com/wiki/example</nowiki> | <nowiki> http://www.example.com/wiki/example</nowiki> | ||
| + | |||
== Installing MediaWiki == | == Installing MediaWiki == | ||
| Line 88: | Line 87: | ||
If all of the above has been done correctly, navigating to the index.php file again should present the MediaWiki installation. | If all of the above has been done correctly, navigating to the index.php file again should present the MediaWiki installation. | ||
| − | <nowiki>http://wwww.EXAMPLE.COM/wiki/index.php | + | <nowiki>http://wwww.EXAMPLE.COM/wiki/index.php |
or | or | ||
http://A.B.C.D/wiki/index.php</nowiki> | http://A.B.C.D/wiki/index.php</nowiki> | ||
| + | |||
| + | |||
| + | == Changing The Logo In The Upper Left == | ||
| + | To change the image in the upper left corner of the Main Page and all other pages on the Wiki, the desired image needs to be uploaded to the server and placed in the '/wiki/images' directory. | ||
| + | |||
| + | For best results, the image should be no larger than 135x135 pixels in size and be .png, .svg, or .jpeg filetypes. | ||
| + | |||
| + | To accomplish uploading the desired image to the server, the below command can be used: | ||
| + | <nowiki>scp /path/to/desired/image.png USER@A.B.C.D:/path/to/destination</nowiki> | ||
| + | |||
| + | If the image was not placed in the '/wiki/images' directory already, the following command will relocate it to the correct directory: | ||
| + | <nowiki>mv /path/to/desired/image.png /path/to/wiki/images/image.png</nowiki> | ||
| + | |||
| + | Then navigate within the server to the LocalSettings.php file placed on the server in the steps above. This will be located at '/wiki/LocalSettings.php' by default. | ||
| + | |||
| + | In this file, add the below to the bottom of the LocalSettings.php file: | ||
| + | <nowiki>$wgLogo = "{wgScriptPath}/images/IMAGE_NAME.[png, svg, jpeg]"; | ||
| + | |||
| + | Using ONLY the correct file format for the file that has been uploaded.</nowiki> | ||
| + | |||
| + | Once the image is in the correct directory and the LocalSettings.php file is pointing to its correct location with the $wgLogo variable, clearing the cache on the browser and reloading the Wiki should show the new image in the upper left. | ||
| + | |||
| + | If additional documentation for the Logo is needed, see [https://www.mediawiki.org/wiki/Manual:$wgLogos here.] | ||
== Potential Suggestions == | == Potential Suggestions == | ||
| − | There may also be a need to run the below command to reset the security context on the LocalSettings.php file in order for it to work correctly. This can be done via: | + | There may also be a need to run the below command to reset the security context for SELinux on the LocalSettings.php file in order for it to work correctly. This can be done via: |
| − | <nowiki>sudo restorecon -r /var/www/html/wiki | + | <nowiki>sudo restorecon -r /var/www/html/wiki</nowiki> |
== Additional Resources == | == Additional Resources == | ||
[https://www.mediawiki.org/wiki/Manual:Installing_MediaWiki MediaWiki Documentation Wiki] | [https://www.mediawiki.org/wiki/Manual:Installing_MediaWiki MediaWiki Documentation Wiki] | ||
Latest revision as of 01:36, 26 March 2026
Prerequisites
A server with the LAMP stack is required to run MediaWiki, a Wiki on how to accomplish that can be found here. If the server to be used already has the LAMP stack installed and running, this Prerequisites section can be skipped.
Installing The Correct Packages For PHP
As of writing, MediaWiki requires PHP 7.3.19-24, 7.4.3, or later and will need to be installed manually.
sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm
sudo dnf module reset php sudo dnf module install php:remi-8.0
Install the module to support the use of MariaDB:
sudo dnf install php-mysqlnd
This may already be installed on the server, if so you can move on to the next step without issue.
Restart the Apache httpd.service for the changes to take effect:
sudo systemctl restart httpd.service
Creating A Database for MediaWiki
This guide assumes that MariaDB has already been installed using the LAMP stack Wiki tutorial linked in Prerequisites above, an d will begin by creating a database to be used by MediaWiki.
Log into the MariaDB console using the below:
sudo mysql -u root -p
Provide the root credentials for MariaDB that were created when installing MariaDB.
Create the database MediaWiki will use:
create database WIKI_NAME;
Create a user to manage the database MediaWiki will use:
create user 'EXAMPLE_USER'@'localhost' identified by 'PASSWORD';
Give this new user permissions to access the database MediaWiki will use:
grant all privileges on WIKI_NAME.* to 'EXAMPLE_USER'@'localhost' with grant option;
Exit the MariaDB console via:
exit;
Downloading MediaWiki
The latest release of MediaWiki can be downloaded manually from here (MediaWiki Downloads Page), the latest release with the .tar.gz extension is the desired option for this tutorial.
mediawiki-VERSION will be used as a placeholder name for the mediawiki files, replace VERSION with the latest version that is being downloaded in the following commands.
This release can also be downloaded from the command line on the remote server via the 'wget' tool:
wget https://releases.wikimedia.org/mediawiki/VERSION/mediawiki-VERSION.tar.gz
However the files were retrieved, move the downloaded files to the Apache document directory (typically '/var/www/html/' or wherever is specified in the '/etc/httpd/conf/httpd.conf' file):
sudo mv mediawiki-VERSION.tar.gz /var/www/html/
Navigate to the document directory those files were relocated, in this tutorial's case '/var/www/html':
cd /var/www/html/
Extract the files from the downloaded tarball:
sudo tar xvzf /var/www/html/mediawiki-VERSION.tar.gz
Extracting this tarball using sudo will make the root user the owner of the files, if another outcome is desired, the 'chown' command can be used to correct this.
If the 'tar' command is not installed on the server:
sudo dnf install tar
Rename the extracted folder to whatever is desired, knowing that the name of this folder will be included in all URL's for this Wiki:
sudo mv /var/www/html/mediawiki-VERSION /var/www/html/wiki
In this case, 'wiki' will be included in all URLs for this Wiki, i.e.:
http://www.example.com/wiki/example
Installing MediaWiki
From a web browser the below URL should now be accessible to configure the MediaWiki installation via the webGUI:
http://wwww.EXAMPLE.com/wiki/index.php or http://A.B.C.D/wiki/index.php
Follow the setup link and navigate through the setup steps until prompted for a database to be provided. Provide the MariaDB database name, username, password for that user.
When setup is complete, MediaWiki will generate a LocalSettings.php file that needs to be downloaded to the server for use.
This can be downloaded to a local machine and copied to the remote server for use via the below:
scp /path/to/downloaded/LocalSettings.php USER@A.B.C.D:/path/to/destination/file
Once the file is on the remote server, move it to the WikiMedia directory:
sudo mv /path/to/LocalSettings.php /var/www/html/wiki/LocalSettings.php
The permissions for this file will need to be adjusted via the below:
sudo chmod 664 /var/www/html/wiki/LocalSettings.php
Ownership of the file may also need to be corrected via:
sudo chown USER:USER LocalSettings.php
If all of the above has been done correctly, navigating to the index.php file again should present the MediaWiki installation.
http://wwww.EXAMPLE.COM/wiki/index.php or http://A.B.C.D/wiki/index.php
Changing The Logo In The Upper Left
To change the image in the upper left corner of the Main Page and all other pages on the Wiki, the desired image needs to be uploaded to the server and placed in the '/wiki/images' directory.
For best results, the image should be no larger than 135x135 pixels in size and be .png, .svg, or .jpeg filetypes.
To accomplish uploading the desired image to the server, the below command can be used:
scp /path/to/desired/image.png USER@A.B.C.D:/path/to/destination
If the image was not placed in the '/wiki/images' directory already, the following command will relocate it to the correct directory:
mv /path/to/desired/image.png /path/to/wiki/images/image.png
Then navigate within the server to the LocalSettings.php file placed on the server in the steps above. This will be located at '/wiki/LocalSettings.php' by default.
In this file, add the below to the bottom of the LocalSettings.php file:
$wgLogo = "{wgScriptPath}/images/IMAGE_NAME.[png, svg, jpeg]";
Using ONLY the correct file format for the file that has been uploaded.
Once the image is in the correct directory and the LocalSettings.php file is pointing to its correct location with the $wgLogo variable, clearing the cache on the browser and reloading the Wiki should show the new image in the upper left.
If additional documentation for the Logo is needed, see here.
Potential Suggestions
There may also be a need to run the below command to reset the security context for SELinux on the LocalSettings.php file in order for it to work correctly. This can be done via:
sudo restorecon -r /var/www/html/wiki