DEV Community

Cover image for Install MediaWiki on Ubuntu using the terminal
MuthuKumar
MuthuKumar

Posted on • Updated on

Install MediaWiki on Ubuntu using the terminal

To install MediaWiki on Ubuntu using the terminal, you can follow these steps:

  1. Update System Packages: Open a terminal and update your system's package list to ensure you have the latest information about available packages.
   sudo apt update
Enter fullscreen mode Exit fullscreen mode
  1. Install Required Packages: MediaWiki requires a web server (typically Apache), a database (usually MySQL or MariaDB), and PHP. Install these packages:
   sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql php-cli php-gd php-xml php-mbstring php-xmlrpc
Enter fullscreen mode Exit fullscreen mode

During the installation of MySQL server, you will be prompted to set a root password for MySQL.

  1. Create MySQL Database and User: Log in to MySQL and create a new database and user for MediaWiki.
   sudo mysql -u root -p
Enter fullscreen mode Exit fullscreen mode

Once inside the MySQL console:

   CREATE DATABASE mediawiki;
   CREATE USER 'mediawikiuser'@'localhost' IDENTIFIED BY 'your_password_here';
   GRANT ALL PRIVILEGES ON mediawiki.* TO 'mediawikiuser'@'localhost';
   FLUSH PRIVILEGES;
   EXIT;
Enter fullscreen mode Exit fullscreen mode

Replace 'your_password_here' with a strong password of your choice.

  1. Download and Extract MediaWiki: Navigate to the /var/www/html directory and download the latest version of MediaWiki. You can find the link to the latest version on the MediaWiki website.
   cd /var/www/html
   sudo wget https://releases.wikimedia.org/mediawiki/1.37/mediawiki-1.37.0.tar.gz
   sudo tar -xzvf mediawiki-1.37.0.tar.gz
   sudo mv mediawiki-1.37.0 mediawiki
   sudo chown -R www-data:www-data mediawiki
Enter fullscreen mode Exit fullscreen mode

Adjust the version number as needed.

  1. Configure Apache: Create a virtual host configuration file for MediaWiki.
   sudo nano /etc/apache2/sites-available/mediawiki.conf
Enter fullscreen mode Exit fullscreen mode

Add the following configuration:

   <VirtualHost *:80>
       ServerAdmin webmaster@localhost
       DocumentRoot /var/www/html/mediawiki
       ServerName your_domain_or_ip
       ErrorLog ${APACHE_LOG_DIR}/error.log
       CustomLog ${APACHE_LOG_DIR}/access.log combined
   </VirtualHost>
Enter fullscreen mode Exit fullscreen mode

Replace your_domain_or_ip with your server's domain name or IP address.

Enable the virtual host and reload Apache:

   sudo a2ensite mediawiki.conf
   sudo systemctl reload apache2
Enter fullscreen mode Exit fullscreen mode
  1. Complete Installation via Web Browser:
    Open a web browser and navigate to http://your_domain_or_ip. Follow the on-screen instructions to complete the MediaWiki installation. You'll need to enter the database details and set up an admin account.

  2. Finalize Configuration:
    After the installation, you may need to adjust some permissions and settings. Refer to the MediaWiki Installation Guide for further information.

Remember that software versions and URLs may change over time, so make sure to refer to the official MediaWiki documentation for the most up-to-date instructions.

Try it YourSelf:

Top comments (0)