Skip to content
Follow
CMS

How to install MediaWiki with Nginx on Ubuntu 24.04

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

You install MediaWiki with Nginx on Ubuntu 24.04 to build your own custom wiki. MediaWiki is the free, open-source wiki software that powers Wikipedia, and Nginx is a popular, high-performance web server.

This setup is perfect for creating a personal knowledge base or a collaborative project wiki. You’ll get a fast and efficient platform for managing your content.

We’ll configure Nginx as a reverse proxy, which helps MediaWiki handle lots of traffic smoothly. This guide focuses on Ubuntu 24.04, giving you the latest tools for your wiki server.

⚡ Quick Answer

Install Nginx and MariaDB servers using apt commands. Create a MediaWiki database and user in MariaDB. Then, install PHP-FPM and necessary extensions with apt.

Install Nginx HTTP server on Ubuntu

To run MediaWiki, you first need a web server, and we’ll use Nginx for this guide on Ubuntu 24.04. Installing Nginx is simple using the apt package manager in your Ubuntu terminal. Just run ‘sudo apt update’ followed by ‘sudo apt install nginx’ to get it set up.

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

🐧Bash / Shell
sudo apt update
sudo apt install nginx

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

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

You can test the Nginx web server by opening your web browser and browsing to the server’s local host or IP address.

http://localhost

Default Welcome to Nginx page displayed after installation on Ubuntu 24.04
Default Welcome to Nginx page displayed after installation on Ubuntu 24.04

When you see “Welcome to nginx!” the Nginx HTTP server has been installed.

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

How to install Nginx on Ubuntu

Install MariaDB database server on Ubuntu

MediaWiki needs a database to store its information, and we’ll use MariaDB for this tutorial on Ubuntu. You can install the MariaDB database server easily from the Ubuntu terminal. Simply type ‘sudo apt update’ and then ‘sudo apt install mariadb-server’ to begin.

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 setting up MariaDB, you need to create a specific database for MediaWiki to use. We’ll create a database named ‘mediawikidb’ and a user called ‘mediawikidbuser’ for it. This user will have full control over the ‘mediawikidb’ database, ensuring MediaWiki can store and retrieve its data.

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-FPM on Ubuntu

MediaWiki is built with PHP, so you’ll need PHP-FPM to run it on your Ubuntu server. This guide installs the necessary PHP packages, including PHP-FPM, which helps manage PHP processes efficiently. Just run the command ‘sudo apt install php-fpm 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’ in your terminal.

Run the commands below to install PHP-FPM.

🐧Bash / Shell
sudo apt install php-fpm 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

Now it’s time to get the MediaWiki software itself onto your Ubuntu server. You can download the latest version directly from the official MediaWiki website. Make sure to check their download page for the most current release link and then use a command like ‘wget [download-link]’ in your /tmp/ directory to download 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 Nginx root directory.

The final step is to change the permissions. This will allow the Nginx 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 Nginx webserver to serve the MediaWiki content.

Run the commands below to create a Nginx server block file for MediaWiki.

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

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

🐘PHP
server {
listen 80;
listen [::]:80;
server_name mediawiki.example.com;

root /var/www/mediawiki;
index index.php;

error_log /var/log/nginx/mediawiki.error;
access_log /var/log/nginx/mediawiki.access;

location / {
try_files $uri $uri/ /index.php;
}

location ~ .php$ {
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include snippets/fastcgi-php.conf;
}
}

Save the file.

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

🐧Bash / Shell
sudo ln -s /etc/nginx/sites-available/mediawiki.conf /etc/nginx/sites-enabled/
sudo systemctl restart nginx.service

Setup Let’s Encrypt SSL/TLS for MediaWiki

To keep your MediaWiki site secure, it’s a good idea to set up an SSL/TLS certificate using Let’s Encrypt. This will allow your site to use HTTPS, encrypting data between your users and the server. You can follow a separate guide on setting up Let’s Encrypt with Nginx on Ubuntu for detailed steps.

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

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

Once you have restarted the Nginx web server, open your browser and browse to the server hostname or IP address defined in the Nginx 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:

  • Setting up a MediaWiki site on Ubuntu with Nginx provides high performance and low memory usage, ensuring the system’s future-proofing.
  • Nginx’s capability to handle concurrent connections and support for essential features like reverse proxy, load balancing, and SSL/TLS encryption make it a scalable solution for MediaWiki installations.
  • The installation process for smooth implementation included setting up Nginx and MariaDB, creating a MediaWiki database, installing PHP-FPM, downloading MediaWiki files, and setting up Let’s Encrypt SSL/TLS.
  • The post also guided through the MediaWiki setup wizard, demonstrating how to complete the installation and ensure the Wiki site is ready to use.

Does nginx work on Ubuntu?

Nginx is available in Ubuntu's default repositories. Install it using the apt packaging system. First, update the local package index to access the most recent package listings, then install nginx : sudo apt update.

How much RAM do I need for MediaWiki?

The recommended minimum requirements are 256MB of RAM for a single-computer website and 85MB of storage, although this will not suffice for a busy public site or a site with uploading enabled. Some users have reported running MediaWiki on computers with as little as 48MB of RAM.

How to reload nginx config in Ubuntu?

To reload your configuration, you can stop or restart NGINX, or send signals to the master process. A signal can be sent by running the nginx command (invoking the NGINX executable) with the -s argument. where can be one of the following: quit – Shut down gracefully (the SIGQUIT signal)

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

How to Start, Stop, and Restart Services in Windows 11
Windows How to Start, Stop, and Restart Services in Windows 11
How to Re-enable TLS 1.0 and 1.1 on Windows 11
Windows How to Re-enable TLS 1.0 and 1.1 on Windows 11

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

Leave a Comment

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