Personal wiki

Hosting a personal wiki on your Linux system can be a great way to keep your notes, documentation, and ideas organized. Here is a step-by-step guide to setting up a personal wiki using MediaWiki:

Step 1: Install Apache, MySQL, and PHP (LAMP Stack)

First, you need to install the LAMP stack (Linux, Apache, MySQL, PHP). Open a terminal and run the following commands:

sudo apt update
sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql php-intl php-xml php-mbstring php-gd php-cli php-zip wget -y
Step 2: Secure MySQL

Secure your MySQL installation:

sudo mysql_secure_installation

Follow the prompts to set a root password and remove anonymous users, disallow root login remotely, and remove the test database.

Step 3: Create a MySQL Database and User for MediaWiki

Log in to MySQL and create a database and user:

sudo mysql -u root -p

Then enter the following commands in the MySQL prompt:

CREATE DATABASE mediawiki;
CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON mediawiki.* TO 'wikiuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace password with a strong password.

Step 4: Download and Install MediaWiki

Download the latest version of MediaWiki:

cd /var/www/html
sudo wget https://releases.wikimedia.org/mediawiki/1.39/mediawiki-1.39.0.tar.gz
sudo tar -xvzf mediawiki-1.39.0.tar.gz
sudo mv mediawiki-1.39.0 mediawiki
sudo chown -R www-data:www-data /var/www/html/mediawiki
Step 5: Configure Apache for MediaWiki

Create a new Apache configuration file for MediaWiki:

sudo vim /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
    <Directory /var/www/html/mediawiki/>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Enable the new site and the rewrite module, then restart Apache:

sudo a2ensite mediawiki.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
Step 6: Complete MediaWiki Setup via Web Browser

Open a web browser and navigate to http://your_server_ip/mediawiki. Follow the on-screen instructions to complete the setup:

  • Choose your language and click Continue.
  • Ensure that the environment checks pass and click Continue.
  • Enter the database details:
    • Database type: MySQL
    • Database name: mediawiki
    • Database username: wikiuser
    • Database password: the password you set earlier
  • Enter your wiki name and set up the admin account.
  • Follow the remaining steps and download the LocalSettings.php file when prompted.
  • Upload the LocalSettings.php file to the /var/www/html/mediawiki directory:
  • sudo mv ~/Downloads/LocalSettings.php /var/www/html/mediawiki/
    sudo chown www-data:www-data /var/www/html/mediawiki/LocalSettings.php
Step 7: Access Your Wiki

You can now access your personal wiki at http://your_server_ip/mediawiki. Log in with the admin account you created and start adding content.