This page is the post-install companion to the main Ubuntu guide: How to Install MediaWiki on Ubuntu 22.04. Use it after the initial MediaWiki setup has completed and LocalSettings.php is already in place.
The goal here is not to repeat the base install. It is to handle the operational work that usually comes next: Apache cleanup, HTTPS, friendly URLs, uploads, permissions, backups, and basic hardening.
When should you use this page?
- When MediaWiki already loads in the browser and the installer is complete
- When you need to tune Apache or add HTTPS
- When you want to enable uploads or review file permissions
- When you want a cleaner production configuration after a successful install
Step 1: Confirm LocalSettings.php is in the document root
Your MediaWiki installation is not really complete until the generated configuration file is in place.
ls -l /var/www/mediawiki/LocalSettings.php
If it is missing, go back to the main install guide and move the downloaded file into /var/www/mediawiki/.
Step 2: Tighten your Apache virtual host
Keep the site configuration clean and make sure the correct document root and rewrite settings are present.
sudo nano /etc/apache2/sites-available/mediawiki.conf
<VirtualHost *:80>
ServerName wiki.example.com
DocumentRoot /var/www/mediawiki
<Directory /var/www/mediawiki>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/mediawiki-error.log
CustomLog ${APACHE_LOG_DIR}/mediawiki-access.log combined
</VirtualHost>
sudo apache2ctl configtest
sudo systemctl reload apache2
Step 3: Review key LocalSettings.php options
Once the base installer has generated LocalSettings.php, review the settings that matter most for a production wiki.
sudo nano /var/www/mediawiki/LocalSettings.php
Typical post-install options to review include:
$wgSitename = 'My Wiki';
$wgServer = 'https://wiki.example.com';
$wgScriptPath = '';
$wgEnableUploads = true;
$wgEmergencyContact = '[email protected]';
$wgPasswordSender = '[email protected]';
Do not copy values blindly. Set them to the real hostname and email addresses for your environment.
Step 4: Enable clean URLs
MediaWiki works without short URLs, but production sites often want friendlier page paths. First make sure Apache rewrite support is enabled.
sudo a2enmod rewrite
sudo systemctl reload apache2
Then add the appropriate short URL configuration in LocalSettings.php and update the Apache site rules to match your chosen rewrite pattern.
Step 5: Enable HTTPS
For any public or semi-public wiki, HTTPS should be standard. If you are using Let’s Encrypt on Ubuntu, the usual path is:
sudo apt install -y certbot python3-certbot-apache
sudo certbot --apache -d wiki.example.com
After certificates are issued, update $wgServer in LocalSettings.php so it uses the HTTPS URL.
Step 6: Review uploads and permissions
If your wiki needs file uploads, confirm that uploads are enabled and that the web server can write only where it needs to.
sudo chown -R www-data:www-data /var/www/mediawiki/images
sudo find /var/www/mediawiki -type d -exec chmod 755 {} \;
sudo find /var/www/mediawiki -type f -exec chmod 644 {} \;
Be careful not to grant broad write access to the whole document root. MediaWiki mainly needs write access for uploads and any explicitly configured cache directories.
Step 7: Back up the wiki properly
A usable MediaWiki backup includes both the database and the uploaded files directory.
mysqldump -u root -p mediawiki > mediawiki-backup.sql
sudo tar -czf mediawiki-images-backup.tar.gz /var/www/mediawiki/images
Store backups off the server and test restore steps before you need them in anger.
Step 8: Keep the wiki patched
MediaWiki releases frequent security and maintenance updates. Follow the supported branches and patch within the release family you are running. If you are on Ubuntu 22.04 with PHP 8.1, the supported long-term path is MediaWiki 1.43 LTS until you are ready for a PHP or OS upgrade.
Step 9: Validate the production setup
- Confirm Apache configuration is valid
- Confirm HTTPS is active if the wiki is public
- Test login, edit, and upload flows
- Review
/var/log/apache2/mediawiki-error.logfor startup errors - Verify database and file backups are completing successfully
Where this guide fits in the cluster
The install path starts on the main page: How to Install MediaWiki on Ubuntu 22.04. This companion page is for the configuration and hardening work that comes after the installer completes.

