Skip to content
Follow
CMS

How to install MediaWiki with Nginx on Ubuntu 24.04

Richard
Written by
Richard
Jun 3, 2024 Updated Jul 13, 2026 8 min read
MediaWiki featured image
MediaWiki featured image

Installing MediaWiki with Nginx on Ubuntu 24.04 lets you create your own custom wiki.

MediaWiki is the free software that runs Wikipedia, and Nginx is a fast web server that handles lots of visitors well.

This setup is great for making a personal notebook for your own information or a wiki for a group project. You get a quick way to keep track of your content.

Nginx helps MediaWiki handle many people visiting the wiki at the same time. This guide focuses on Ubuntu 24.04, giving you the latest way to set up 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

Nginx is a web server that helps your MediaWiki site run on Ubuntu 24.04. To install Nginx, open the terminal and type ‘sudo apt update’ to refresh your package list, then run ‘sudo apt install nginx’ to get Nginx installed.

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

Your MediaWiki site needs a database to keep all its information, and MariaDB is a great option for your Ubuntu server. You can install the MariaDB database server using the terminal by first running ‘sudo apt update’ and then typing ‘sudo apt install mariadb-server’.

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

MediaWiki requires its own special database to store and find all your wiki’s information. This guide shows you how to create a database named ‘mediawikidb’ and a user called ‘mediawikidbuser’ that will have full control, ensuring MediaWiki can manage its data correctly.

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

PHP-FPM helps MediaWiki run smoothly on your Ubuntu server because MediaWiki is built using PHP. To install PHP-FPM and other necessary PHP packages like php-intl and php-mysql, open your terminal and 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’.

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

You can download the latest MediaWiki software directly from its official website. Visit the MediaWiki download page to find the link for the newest version, and then use a command like ‘wget [download-link]’ in your server’s /tmp/ folder to download the files. Always check the site for the most current release.

⚠️Warning
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.

📝Good to Know
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.

You can enable the virtual host by running the command `sudo ln -s /etc/nginx/sites-available/your_domain.conf /etc/nginx/sites-enabled/` and then restart the Nginx server with `sudo systemctl restart nginx` to apply the changes.

🐧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

Securing your MediaWiki site with HTTPS is important, and Let’s Encrypt provides free SSL/TLS certificates to make it safe. This ensures that information shared between users and your server is encrypted. You can set up Let’s Encrypt with Nginx on Ubuntu by following a separate guide.

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 `LocalSettings.php` file stores your wiki's setup choices. Download the `LocalSettings.php` file and place `LocalSettings.php` in the same folder as `index.php` within your wiki's installation directory. If the `LocalSettings.php` file download does not begin, you can click the "Download LocalSettings.php" link again. You cannot retrieve the generated `LocalSettings.php` file later if you exit the installation without downloading `LocalSettings.php`.

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 Install Nginx on Ubuntu Linux
Ubuntu Linux How to Install Nginx on Ubuntu Linux
How to Setup Let's Encrypt with Nginx on Ubuntu Linux
Ubuntu Linux How to Setup Let's Encrypt with Nginx on Ubuntu Linux
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 *