Skip to content
Follow
CMS

How to Install MediaWiki with Nginx on Ubuntu 24.04

Richard
Written by
Richard
Jun 3, 2024 Updated Sep 15, 2026 7 min read
MediaWiki featured image
MediaWiki featured image

MediaWiki with Nginx on Ubuntu 24.04 sets up your own private wiki site on a fast web server. MediaWiki is the free software that runs Wikipedia, and Nginx is the speedy web server that loads your pages quickly for visitors.

Advertisement

This setup works well for a team project or a personal note-taking site. Ubuntu 24.04 gives you the latest security updates and stable software to keep your wiki running without trouble.

⚡ 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.

Advertisement

Install Nginx HTTP server on Ubuntu

Nginx is a web server you need to run your MediaWiki site on Ubuntu 24.04. To install Nginx, open your terminal and run the commands sudo apt update followed by sudo apt install nginx to download and set up the web server on your system.

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.

Advertisement

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

Advertisement

Install MariaDB database server on Ubuntu

MariaDB is the database server your MediaWiki site uses to store all its articles and user data on Ubuntu 24.04. To install MariaDB, open your terminal and run the update command followed by sudo apt install mariadb-server to get the database running.

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.

Advertisement
🐧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.

Advertisement

Create a MediaWiki database

MediaWiki requires a dedicated database and a user account with full permissions to store and manage your wiki content. You can create the database named mediawikidb and a corresponding user called mediawikidbuser by logging into the MariaDB command prompt and running the required SQL setup commands.

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:

Advertisement

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
⚠️WarningEnsure to replace 'type_your_password_here 'with your password.

Install PHP-FPM on Ubuntu

PHP-FPM is required because MediaWiki is built using PHP and needs these extensions to process site requests on your Ubuntu server. To install PHP-FPM along with necessary modules like php-mysql and php-intl, open your terminal and run the apt install command with all the required package names.

Advertisement

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

MediaWiki installation files are available directly from the official website as a compressed archive. You can download the latest version of the software straight to your server by visiting the official release page, grabbing the direct download link, and using the wget command inside your server temporary folder.

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

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

Let's Encrypt provides free SSL/TLS certificates to secure your MediaWiki site with HTTPS and encrypt traffic between users and your server. You can set up these security certificates alongside your Nginx web server on Ubuntu by following a dedicated configuration 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.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.

Advertisement

📚 Related Tutorials

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 Install Nginx on Ubuntu Linux
Ubuntu Linux How to Install 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 *