How to install MediaWiki with Apache on Ubuntu 24.04
MediaWiki on Ubuntu 24.04 sets up a private wiki site using the exact same free software that powers Wikipedia. Ubuntu 24.04 (released in April 2024) provides the Linux operating system, while the Apache web server puts your wiki pages online.
You can build your own knowledge base by running this software stack on your server. Follow the steps below to set everything up and get your wiki online.
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
You can install Apache HTTP server on Ubuntu Linux by running two quick commands in your terminal. First, update your system package list with sudo apt update, and then run sudo apt install apache2 to download and set up the web server. Once the installation finishes, Apache starts automatically.
To do that, open the Ubuntu terminal and run the commands below to install the Apache web server.
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.
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

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.
Install MariaDB database server on Ubuntu Linux
You must install MariaDB database server on Ubuntu Linux to store all your MediaWiki site data securely. Open your terminal and run sudo apt update followed by sudo apt install mariadb-server to set up the database software on your system.
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.
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.
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.
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.
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.
- How to install MariaDB on Ubuntu Linux
- MariaDB without password prompt
Create a MediaWiki database
You create a MediaWiki database by logging into the MariaDB command line and running SQL queries to set up a dedicated database and user account. This gives your wiki the necessary storage and secure login credentials to save pages and user accounts properly.
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:
sudo mariadb
Then run the commands below to complete the steps:
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
Install PHP on Ubuntu Linux
You install PHP on Ubuntu Linux by running an apt command that includes PHP and all the required modules like php-mysql and php-xml. MediaWiki relies on PHP to process code and display your wiki pages correctly in web browsers.
Run the commands below to install PHP.
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
Download MediaWiki files
You download MediaWiki files directly to your Ubuntu server by opening your terminal, moving to the /tmp/ directory, and using the wget command to grab the latest release package from the official download page.
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.
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.
sudo nano /etc/apache2/sites-available/mediawiki.conf
Then, copy and paste the content block below into the Apache server block.
<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.
You can enable the virtual host for MediaWiki and restart the Apache server using specific commands. This action makes the MediaWiki site accessible through your web browser after the installation.
sudo a2ensite mediawiki.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
Setup Let's Encrypt SSL/TLS for MediaWiki
You set up Let's Encrypt SSL/TLS for MediaWiki by installing Certbot and generating a free security certificate for your Apache web server. This encrypts traffic between your users and your wiki to protect passwords and personal data.
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.
http://mediawiki.example.com
A MediaWiki installation wizard page should appear. Click the 'Please set up the wiki first' link and continue.

Next, select the installation language and continue.

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

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

Next, click Continue to begin the installation.

Your MediaWiki site should be set up but not ready to use. Follow the instructions below to complete the setup.
The `LocalSettings.php` file saves your wiki's special settings and must be downloaded and placed in the wiki's main folder, next to the `index.php` file. If the `LocalSettings.php` download does not begin, you can click the "Download LocalSettings.php" link again. Without downloading `LocalSettings.php`, your setup changes will disappear upon leaving the installation. After downloading `LocalSettings.php`, you can open your wiki.
Copy the 'LocalSettings.php' file into the root directory where Mediawiki files are stored.
sudo cp ~/Downloads/LocalSettings.php /var/www/mediawiki

Your Wiki site should be ready to use.

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?
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.
No comments yet — be the first to share your thoughts!