Skip to main content

MediaWiki

Version: 1.39   |   OS: Ubuntu 22.04

Overview

MediaWiki is a free and open-source wiki platform used by Wikipedia and thousands of other collaborative knowledge bases. Developed and maintained by a vibrant open-source community, it is known for its scalability, flexibility, and powerful content management capabilities.

Included Software

  • Apache - 2.4.41
  • MySQL - 8.0.32
  • PHP - 7.4
  • Postfix - 3.4.13
  • MediaWiki - 1.39

Getting Started

Firewall & Access

After deployment, ensure your firewall allows only the following ports:

PortServicePurpose
22SSH (rate limited)Secure server access
80HTTPWeb access
443HTTPSSecure web access

Initial Deployment

On first boot, MySQL is secured and the root password is set. You will be logged out of SSH with the message:

Please wait until the installation is completed....
Connection to $IPADDRESS closed.

Important: Wait at least 2 minutes before logging in to allow full setup.

Accessing the Instance

  • SSH Access: Log in as ubuntu, then elevate to root:
sudo su -
  • MySQL Credentials:

    • Stored in /root/.mysql_root_password
    • Login:
      mysql -u root -p
  • MediaWiki Database Info: /root/.mediawiki_database_details

  • Admin Login Credentials: /root/.mediawiki_admin_details

Accessing MediaWiki

Visit the MediaWiki dashboard at:

http://$IPADDRESS/mediawiki

Or via a configured domain name.

Trusted Configuration

For IP Access

Allow access using:

sed -i 's/$wgServer = "http:\/\/localhost";/$wgServer = "http:\/\/$my_ip";/g' /var/www/html/mediawiki/LocalSettings.php

Restart Apache:

systemctl restart apache2

For Domain Access

Ensure your domain's A record points to the instance IP. Then:

  • Set the Apache ServerName:
sed -i 's/#ServerName $my_domain/ServerName $my_domain/g'
  • Update MediaWiki config:
sed -i 's/$wgServer = "http:\/\/localhost";/$wgServer = "http:\/\/$my_domain";/g' /var/www/html/mediawiki/LocalSettings.php

Restart Apache again:

systemctl restart apache2

Optional: Root Access to MediaWiki

If you want to access MediaWiki directly at http://$IPADDRESS (instead of /mediawiki), add an .htaccess rule:

vi /var/www/html/.htaccess

Paste the following and save (:wq):

RewriteEngine On
RewriteRule ^$ /mediawiki [L]

Configuring Postfix

Set a Valid Hostname

hostnamectl set-hostname your.hostname.com

Ensure proper A and PTR DNS records exist.

Update Postfix Configuration

Edit /etc/postfix/main.cf:

myhostname = your.hostname.com

Restart Postfix:

systemctl restart postfix

Test Email Delivery

echo "Postfix test" | mail -s "Subject" test@gmail.com

Note: Emails may initially land in spam. As the IP reputation improves, they will reach the inbox.

Best Practices

  • Configure your domain before setting up SSL or public access.
  • Always test configuration changes using Apache test commands before restarting services.
  • Ensure your instance is secured behind a firewall and use strong admin credentials.

For support, contact Cloud4India Support.