MediaWiki: Tutorial & Best Practices
Introduction to MediaWiki
If you've ever used Wikipedia, then congratulations—you're already familiar with MediaWiki! MediaWiki is a free and open-source wiki software that powers not just Wikipedia but thousands of other wikis across the web. It's perfect for setting up your own collaborative documentation site, whether for personal use, a small team, or even a large organization.
Why Use MediaWiki?
MediaWiki is a robust and flexible platform for collaborative documentation. Here are some of the reasons why it stands out:
- Version Control: Every edit is tracked, so you can see who changed what and when.
- User Management: You can set up different user roles and permissions.
- Extensions: A vast library of extensions to add functionality.
- Scalability: Works well for small wikis and scales up to large ones.
Installing MediaWiki
Before you can start collaborating, you'll need to install MediaWiki on your Linux server. Here’s a straightforward way to get it done:
Update Your System: Make sure your server is up to date.
sudo apt update && sudo apt upgrade -y
Install Apache, PHP, and MySQL: MediaWiki requires these to run.
sudo apt install apache2 php libapache2-mod-php mysql-server php-mysql
Download and Extract MediaWiki: Download the latest version from the official site.
wget https://releases.wikimedia.org/mediawiki/1.37/mediawiki-1.37.0.tar.gz tar -xvzf mediawiki-1.37.0.tar.gz sudo mv mediawiki-1.37.0 /var/www/html/mediawiki
Set Up Database: Create a MySQL database and user for MediaWiki.
sudo mysql -u root -p CREATE DATABASE mediawiki; CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON mediawiki.* TO 'wikiuser'@'localhost'; FLUSH PRIVILEGES; EXIT;
Configure Apache: Configure Apache to serve your MediaWiki site.
sudo nano /etc/apache2/sites-available/mediawiki.conf
Add the following configuration:
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html/mediawiki ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Enable the new site and restart Apache:
sudo a2ensite mediawiki.conf sudo systemctl restart apache2
Complete Installation: Navigate to
http://your_server_ip/mediawiki
in your browser and follow the on-screen instructions to complete the installation.
Common Problems & Troubleshooting
Permissions Issues
One common issue is permissions. If your server throws a permissions error, make sure the mediawiki
directory is writable by the web server:
sudo chown -R www-data:www-data /var/www/html/mediawiki
PHP Configuration
Sometimes, PHP settings can cause issues. Make sure the necessary PHP extensions are enabled and tweak your php.ini
file if needed:
sudo nano /etc/php/7.4/apache2/php.ini
Look for settings related to file_uploads
, upload_max_filesize
, and post_max_size
, and adjust them as necessary.
Database Connection Problems
If MediaWiki can't connect to the database, ensure your database credentials are correct and that the MySQL server is running:
sudo systemctl status mysql
If you see any errors, you might need to restart the service:
sudo systemctl restart mysql
Best Practices for MediaWiki
Regular Backups
Always keep regular backups of your MediaWiki database and files. Use mysqldump
for database backups:
mysqldump -u wikiuser -p mediawiki > mediawiki_backup.sql
Security Updates
Regularly check for and apply security updates to both MediaWiki and your server software. This helps keep your wiki safe from vulnerabilities.
User Management
Properly manage user roles and permissions to prevent unauthorized changes. Use the built-in user management tools to set up different roles like administrators, editors, and viewers.
Conclusion
Setting up MediaWiki on your Linux server can be a game-changer for collaborative documentation. With its powerful features and scalability, it’s a great tool for any project. Just follow the steps above to get started, and keep best practices in mind to maintain a secure and efficient wiki.