This article explains how to install MediaWiki with Nginx on Ubuntu 24.04.
With Nginx as a web server for MediaWiki on Ubuntu, you get high performance and low memory usage, future-proofing your system.
Nginx’s ability to handle many concurrent connections and its support for features like reverse proxy, load balancing, and SSL/TLS encryption, essential for securing and optimizing the performance of a MediaWiki installation, make it a scalable solution.
In summary, Nginx with MediaWiki on Ubuntu promises improved performance, security, and scalability.
The steps below walk you through installing MediaWiki with Nginx support on Ubuntu 24.04.
Install Nginx HTTP server on Ubuntu
MediaWiki requires a web server. This post will install and use the Nginx web server to run MediaWiki.
To do that, open the Ubuntu terminal and run the commands below to install the Nginx web server.
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.
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

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
The next component that is required to run MediaWiki is a database server. This post will install and use the MariaDB database server to run MediaWiki.
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.
Create a MediaWiki database
Upon successfully installing the MariaDB database server, create a blank database on the server specifically for the MediaWiki application.
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
Ensure to replace ‘type_your_password_here ‘with your password.
Install PHP-FPM on Ubuntu
The last component you will need to run MediaWiki is PHP-FPM. The MediaWiki application is PHP-based and supports the latest versions of PHP.
Run the commands below to install PHP-FPM.
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
Let’s begin the straightforward process of downloading and configuring the MediaWiki files on Ubuntu Linux.
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.
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.
sudo nano /etc/nginx/sites-available/mediawiki.conf
Then, copy and paste the content block below into the Nginx server block.
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.
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
You may want to install an SSL/TLS certificate to secure your MediaWiki site. Secure your MediaWiki installation with HTTPS from Let’s Encrypt.
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.
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 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.
sudo cp ~/Downloads/LocalSettings.php /var/www/mediawiki

Your Wiki site should be ready to use.

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.
Leave a Reply