This page is the post-install companion to the main Ubuntu guide: How to Install MediaWiki on Ubuntu 22.04.
Use it after the web installer has completed, MediaWiki loads successfully, and LocalSettings.php is already installed. It covers the operational work that normally follows the initial installation:
- Apache configuration
- HTTPS
- short URLs
- file ownership and permissions
- upload security
- backups
- updates and validation
The examples assume:
Hostname: wiki.example.com
Document root: /var/www/mediawiki
Article URLs: https://wiki.example.com/wiki/Page_Name
Replace these values with those used by your server.
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.
sudo ls -l /var/www/mediawiki/LocalSettings.php
sudo php -l /var/www/mediawiki/LocalSettings.phpIf the file is missing, return to the main installation guide and copy the installer-generated file into:
/var/www/mediawiki/LocalSettings.phpA working wiki already requires this file, so a missing file usually indicates that the wrong installation directory is being inspected.
Step 2: Correct the file ownership and permissions
The Apache and PHP account should not own or be able to modify MediaWiki’s PHP source files. On Ubuntu, that account is normally www-data.
The following example makes root the deployment owner. A dedicated deployment account can be used instead.
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 apache2Step 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.phpTypical 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 apache2Then 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.comAfter 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/imagesStore 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 article covers the configuration, security and operational tasks that follow the web installer.


Leave a Reply