Self-hosted Wikipedia Style Wiki with MediaWiki on Debian 🌱

  1. Log into the Debian device
  2. Run the following commands in a terminal:
    # update repositories and install any available software updates
    sudo apt update
    sudo apt upgrade -y
    # install Apache HTTPD and MySQL
    sudo apt-get install apache2 mariadb-server mariadb-client curl
    # install PHP components
    sudo apt install php php-common php-mysql php-cli php-json php-opcache php-gd php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip
    # configure the MySQL database
    sudo su
    mysql_secure_installation
  3. Press Enter to login as root
  4. Type Y and press Enter to set a root password, type the password twice to confirm
  5. Type Y and press Enter to remove anonymous users
  6. Type Y and press Enter to disallow root login remotely
  7. Type Y and press Enter to remove the test database
  8. Type Y and press Enter to reload privilege tables
  9. Run the following command to login into MySQL:
    mysql -u root -p
  10. Authenticate with the root password set earlier
  11. Run the following commands to create the MediaWiki database and database user
    CREATE DATABASE wikidb;
    GRANT ALL ON wikidb.* TO 'wikiuser'@'localhost' IDENTIFIED BY 'WikiW1k1Wh@t!!';
    FLUSH PRIVILEGES;
    EXIT;
    exit
  12. Continue with the following commands to download and extract MediaWiki in the Apache webroot
    # download latest MediaWiki version
    sudo wget -O mediawiki.tar.gz https://releases.wikimedia.org/mediawiki/1.35/mediawiki-1.35.1.tar.gz
    # extract mediawiki.tar.gz
    sudo tar xzvf mediawiki.tar.gz --directory /var/www/html
    # rename mediawiki folder
    sudo mv /var/www/html/mediawiki* /var/www/html/wiki
    # set the owner of the new wiki directory to www-data
    sudo chown -R www-data:www-data /var/www/html/wiki
    # restart apache2 service
    sudo systemctl restart apache2
  13. Open a web browser and navigate to http://DNSorIP/wiki
  14. Click the set up the wiki first link
  15. Select a language > Click Continue
  16. Scroll to the bottom of the page and click Continue
  17. Enter the database host, name, username and password > Click Continue

    Host: localhost
    Name: wikidb
    Username: wikiuser
    Password: WikiW1k1Wh@t!!

  18. Leave Use the same account as for installation checked and click Continue
  19. Give the Wiki a name and create an administrator username and password
  20. Uncheck the Share data about this installation with MediaWiki developers box
  21. Check the I'm bored already, just install the wiki box
  22. Click Continue and the Continue again to begin the installation
  23. After the installation completes click Continue
  24. Download the generated LocalSettings.php to the Downloads directory
  25. Run the following command in terminal to place the LocalSettings.php in the correct location
    sudo mv ~/Downloads/LocalSettings.php /var/www/html/wiki
  26. Back in the browser click the enter your wiki link
  27. Click the Log In link at the top right
  28. Log in with the administrator account created during the installation 
  29. Welcome to WikiMedia