Setting up MediaWiki on your Ubuntu 24.04 server with Apache allows you to create a powerful, customizable wiki for collaboration, documentation, or knowledge sharing. This step-by-step guide will walk you through the entire process—from installing necessary components to configuring your wiki—so you can have a fully functional MediaWiki site up and running efficiently. Before starting, ensure you have a fresh Ubuntu 24.04 server with root or sudo access, a domain name (optional but recommended), and a stable internet connection.
What You’ll Need
- Ubuntu 24.04 server with root or sudo privileges
- Domain name (optional but recommended for production)
- Basic knowledge of Linux command line
- Internet connection
- Firewall access to allow HTTP/HTTPS traffic
Step-by-Step
- Update your server packages
Open your terminal and run:sudo apt update && sudo apt upgrade -yThis ensures all your packages are up-to-date and minimizes potential conflicts.
- Install Apache, MariaDB, and PHP
Install the necessary components for a LAMP stack:sudo apt install apache2 mariadb-server php libapache2-mod-php php-mysql php-xml php-mbstring php-intl php-gd php-curl php-zip php-bcmath -yConfirm installation completes successfully.
- Secure your MariaDB installation
Run the secure installation script:sudo mysql_secure_installationFollow prompts to set root password, remove anonymous users, disallow root login remotely, and delete test databases.
- Create a database and user for MediaWiki
Log into MariaDB:sudo mysql -u root -pThen execute:
CREATE DATABASE mediawiki CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'your_secure_password'; GRANT ALL PRIVILEGES ON mediawiki.* TO 'wikiuser'@'localhost'; FLUSH PRIVILEGES; EXIT;Replace ‘your_secure_password’ with a strong password.
- Download and extract MediaWiki
Navigate to your web directory and download the latest MediaWiki release:cd /var/www/html sudo wget https://releases.wikimedia.org/mediawiki/1.39/mediawiki-1.39.4.tar.gz sudo tar -xvzf mediawiki-1.39.4.tar.gz sudo mv mediawiki-1.39.4 mediawikiAdjust permissions:
sudo chown -R www-data:www-data /var/www/html/mediawiki - Configure Apache virtual host
Create a new config file:sudo nano /etc/apache2/sites-available/mediawiki.confAdd the following content, customizing your domain or server IP:
<VirtualHost *:80> ServerName yourdomain.com ServerAdmin admin@yourdomain.com DocumentRoot /var/www/html/mediawiki ErrorLog ${APACHE_LOG_DIR}/mediawiki_error.log CustomLog ${APACHE_LOG_DIR}/mediawiki_access.log combined <Directory /var/www/html/mediawiki> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> </VirtualHost>Enable the site and rewrite module, then restart Apache:
sudo a2ensite mediawiki.conf sudo a2enmod rewrite sudo systemctl restart apache2 - Complete MediaWiki installation via web interface
Open your browser and navigate tohttp://yourdomain.comorhttp://server-ip. Follow the on-screen instructions:- Choose language
- Enter database details:
- Database type: MySQL/MariaDB
- Database name: mediawiki
- Database user: wikiuser
- Password: the password you set
- Configure your wiki settings (name, admin account, etc.)
- Finish installation and download the LocalSettings.php file
Upload the LocalSettings.php to your MediaWiki directory if prompted.
Common Mistakes
- Not securing the MariaDB installation, leaving default settings vulnerable
- Using weak passwords for database or admin accounts
- Incorrect permissions on MediaWiki files, causing web server access issues
- Forgetting to enable mod_rewrite or AllowOverride in Apache config
- Skipping the final step of uploading LocalSettings.php, resulting in an incomplete setup
- Not updating your server packages before installation, leading to compatibility issues
Tips
- Use strong, unique passwords for database and admin accounts
- Back up your database and MediaWiki files regularly
- Configure HTTPS using Let’s Encrypt for secure access
- Adjust PHP settings in php.ini for optimal performance (e.g., upload_max_filesize, memory_limit)
- Enable caching mechanisms such as memcached or Redis to speed up your wiki
- Regularly update MediaWiki and server packages to stay secure
Troubleshooting
- Page does not load or shows error: Check Apache error logs at
/var/log/apache2/error.log. Verify permissions and ensure mod_rewrite is enabled. - Database connection errors: Double-check database credentials in LocalSettings.php and ensure MariaDB service is running.
- Permissions issues: Set correct ownership with
chown -R www-data:www-data /var/www/html/mediawiki. - SSL/TLS issues: Use Certbot to install free SSL certificates and update your Apache config accordingly.
- Installation stuck or incomplete: Review the installation steps, ensure all dependencies are installed, and reload the page.
Frequently Asked Questions
1. Can I install MediaWiki without a domain name?
Yes, you can access MediaWiki via your server’s IP address, but using a domain name is recommended for easier access and SSL setup.
2. How do I secure my MediaWiki installation?
Use HTTPS with a free SSL certificate, secure your database, keep software updated, and configure proper permissions.
3. What are the system requirements for MediaWiki on Ubuntu 24.04?
At least 512MB RAM, a modern web server (Apache recommended), PHP 7.4 or higher, and MariaDB or MySQL.
4. How often should I update MediaWiki?
Check for updates regularly, especially security patches, and upgrade when new versions are released.
5. How do I add extensions or themes to MediaWiki?
Download extensions or themes into the ‘extensions’ or ‘skins’ directories, then enable them via LocalSettings.php.
6. Can I migrate an existing wiki to this server?
Yes, by exporting your database and copying your LocalSettings.php and media files, then importing into the new setup.
By following these instructions carefully, you’ll have a robust MediaWiki installation powered by Apache on Ubuntu 24.04, ready for collaboration and knowledge sharing. Remember to maintain security practices and keep your system updated for optimal performance and safety.
Related
- How to Hide the Meet Section in Gmail on a Laptop or Desktop
- How to Hide the Mouse Pointer While Typing in Windows 11
- How to Hide the Home Button in Microsoft Edge