Skip to content
Follow
CMS

How to install MediaWiki with Apache on Ubuntu 24.04

Richard
Written by
Richard
Jun 3, 2024 Updated Mar 20, 2026 7 min read
MediaWiki featured image
MediaWiki featured image

You install MediaWiki with Apache on Ubuntu 24.04 by configuring the Apache web server, downloading the MediaWiki software, and linking them for a functional wiki.

MediaWiki is the free, open-source wiki engine that powers Wikipedia, allowing you to build collaborative knowledge bases. Apache, a popular and powerful web server, will host your MediaWiki instance.

This process lets you create your own private or public wiki, perfect for documentation or team collaboration. You’ll achieve this on a fresh Ubuntu 24.04 server.

⚡ Quick Answer

Install Apache and PHP, then download the MediaWiki software. Configure Apache to serve MediaWiki and complete the setup through its web installer.

Install Apache HTTP server on Ubuntu Linux

To install the Apache web server on Ubuntu Linux, open your terminal and run the commands to update your package list and then install apache2.

To do that, open the Ubuntu terminal and run the commands below to install the Apache web server.

🐧Bash / Shell
sudo apt update
sudo apt install apache2

Once Apache is installed, the commands below can start, stop, and enable the Apache web server to start automatically when your server boots up.

🐧Bash / Shell
sudo systemctl stop apache2
sudo systemctl start apache2
sudo systemctl enable apache2

You can test that the Apache web server is running by opening your web browser and browsing to the server’s localhost or IP address.

http://localhost

Default Apache2 welcome page displayed after successful installation on Ubuntu 24.04
Default Apache2 welcome page displayed after successful installation on Ubuntu 24.04

When you see the Apache2 Default Page, it means the Apache HTTP server is successfully installed.

Additional help on installing Apache on Ubuntu is in the link below.

How to install Apache on Ubuntu

Install MariaDB database server on Ubuntu Linux

You’ll need a database server for MediaWiki, and installing MariaDB on Ubuntu Linux is a good choice; open your terminal and run the update and install commands.

To install and use the MariaDB database server, use the instructions below.

Open the Ubuntu terminal and run the commands below to install the MariaDB database server.

🐧Bash / Shell
sudo apt update
sudo apt install mariadb-server

Once the MariaDB database server is installed, use the commands below to stop, start, and enable the MariaDB server to start automatically when the server boots.

🐧Bash / Shell
sudo systemctl stop mariadb
sudo systemctl start mariadb
sudo systemctl enable mariadb

Run the following commands to validate and test if the MariaDB database server is installed successfully.

🐧Bash / Shell
sudo mariadb

Once you run the commands above, it will log you onto the MariaDB console and display a message similar to the one below.

💻Code
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 32
Server version: 10.11.2-MariaDB-1 Ubuntu 23.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [(none)]> 

The message tells you that the server is installed successfully.

Additional help on installing MariaDB.

Create a MediaWiki database

After installing MariaDB, you need to create a specific database for MediaWiki, which we’ll name ‘mediawikidb’, and set up a user, ‘mediawikidbuser’, giving them full access.

As part of the setup, we will create a database named ‘mediawikidb‘ and a corresponding user account called ‘mediawikidbuser.’

Finally, we’ll grant the mediawikidbuser full access to the mediawikidb database.

All the database steps above can be done using the commands below:

But first, log on to the MariaDB database server:

🐧Bash / Shell
sudo mariadb

Then run the commands below to complete the steps:

💻Code
CREATE DATABASE mediawikidb CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER mediawikidbuser@localhost IDENTIFIED BY 'type_your_password_here';
GRANT ALL ON mediawikidb.* TO mediawikidbuser@localhost WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit

Ensure to replace ‘type_your_password_here ‘with your password.

Install PHP on Ubuntu Linux

MediaWiki runs on PHP, so you need to install it on Ubuntu Linux; open your terminal and run the command to install PHP along with necessary modules like libapache2-mod-php and php-mysql.

Run the commands below to install PHP.

🐧Bash / Shell
sudo apt install php libapache2-mod-php php-intl php-mysql php-curl php-cli php-zip php-xml php-gd php-common php-mbstring php-xmlrpc php-json php-sqlite3 php-soap php-zip

Additional help on installing PHP

How to install PHP on Ubuntu Linux

Download MediaWiki files

Downloading the MediaWiki files for your Ubuntu Linux installation is simple; go to the /tmp/ directory in your terminal, download the latest version from the official page, and then unzip it.

Always check the download page for the latest release. Replace the download link below with the current so you have the latest version.

First, navigate to the /tmp/ directory and download MediaWiki files. After unzipping the file, move the content into the MediaWiki folder in the Apache root directory.

The final step is to change the permissions. This will allow the Apache web server to safely interact with the files, ensuring a secure environment for your MediaWiki installation.

Command Prompt
cd /tmp/
curl -O https://releases.wikimedia.org/mediawiki/1.41/mediawiki-1.41.1.tar.gz
tar -xvzf mediawiki-*.tar.gz
sudo cp -rf mediawiki-*/ /var/www/mediawiki
sudo chown -R www-data:www-data /var/www/mediawiki/

Once all the steps are done, configure the Apache webserver to serve the MediaWiki content.

Run the commands below to create an Apache virtual host file for MediaWiki.

🐧Bash / Shell
sudo nano /etc/apache2/sites-available/mediawiki.conf

Then, copy and paste the content block below into the Apache server block.

💻Code
<VirtualHost *:80>
ServerName mediawiki.example.com
ServerAlias www.mediawiki.example.com
ServerAdmin admin@example.com
DocumentRoot /var/www/mediawiki

<Directory /var/www/mediawiki/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Save the file.

Then, run the commands below to enable the virtual host and restart the Apache server.

🐧Bash / Shell
sudo a2ensite mediawiki.conf
sudo a2enmod rewrite
sudo systemctl restart apache2

Setup Let’s Encrypt SSL/TLS for MediaWiki

To secure your MediaWiki site with HTTPS, you can set up a free Let’s Encrypt SSL/TLS certificate for Apache on Ubuntu Linux by following the linked guide.

Please read the post below for additional resources on installing and creating Let’s Encrypt SSL certificates for Apache.

How to set up Let’s Encrypt SSL certificate for Apache on Ubuntu Linux

Once you have restarted the Apache web server, open your browser and browse to the server hostname or IP address defined in the Apache server block.

💻Code
http://mediawiki.example.com

A MediaWiki installation wizard page should appear. Click the ‘Please set up the wiki first’ link and continue.

MediaWiki set up wizard
MediaWiki set up wizard

Next, select the installation language and continue.

MediaWiki set up installation language
MediaWiki set up installation language

Type the database name, account name, and password on the next screen and click continue.

MediaWiki set up database connection
MediaWiki set up database connection

Next, enter your Wiki name, create an administrator account, and continue.

MediaWiki set up site name and account
MediaWiki set up site name and account

Next, click Continue to begin the installation.

MediaWiki set up install
MediaWiki set up install

Your MediaWiki site should be set up but not ready to use. Follow the instructions below to complete the setup.

The installer has generated a LocalSettings.php file. It contains all your configuration. You will need to download it and put it in the base of your wiki installation (the same directory as index.php). The download should have started automatically. If the download was not offered, or if you cancelled it, you can restart the download by clicking the link below: Download LocalSettings.php. Note: If you do not do this now, this generated configuration file will not be available later if you exit the installation without downloading it. When that has been done, you can enter your wiki.

Copy the ‘LocalSettings.php’ file into the root directory where Mediawiki files are stored.

🐧Bash / Shell
sudo cp ~/Downloads/LocalSettings.php /var/www/mediawiki
MediaWiki set up complete
MediaWiki set up complete

Your Wiki site should be ready to use.

MediaWiki set up main page
MediaWiki set up main page

That should do it!

Conclusion:

  • When installed with Apache on Ubuntu 24.04, MediaWiki creates an environment conducive to fostering collaboration and managing content effectively.
  • The collaborative setup of MediaWiki with Apache on Ubuntu establishes a reliable and flexible environment for hosting wiki content, such as internal documentation, knowledge bases, and collaborative websites.
  • Following the steps, including installing Apache, MariaDB, and PHP and configuring Let’s Encrypt SSL/TLS, you can successfully set up a MediaWiki site with secure HTTPS access.
  • With the comprehensive guidance provided here, you can confidently create a MediaWiki database, download MediaWiki files, configure the Apache server to serve the MediaWiki content, and complete the setup using the installation wizard.
  • This post has illustrated how to seamlessly set up a MediaWiki site on Ubuntu with Apache support, providing an invaluable resource for those seeking to cultivate interactive and information-rich platforms.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

Capture Photos with Cheese on Ubuntu Linux
Ubuntu Linux Capture Photos with Cheese on Ubuntu Linux
How to Uninstall Software in Ubuntu Linux
Ubuntu Linux How to Uninstall Software in Ubuntu Linux
How to Install NetData on Ubuntu 24.04
Ubuntu Linux How to Install NetData on Ubuntu 24.04
How to Install Emby Media Server on Ubuntu 24.04
Ubuntu Linux How to Install Emby Media Server on Ubuntu 24.04

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *