Disclaimer

This blog is kind of my own personal work Notebook, and the processes below are only guaranteed to work for my specific configurations. So, use this info at your own risk, and please understand I won't be able to provide any help if you break something

Saturday, June 1, 2024

Install MediaWiki on a secure, optimized stack with Nginx, MariaDB, and PHP on Ubuntu.

  1. Install Nginx, MariaDB, and PHP:
sudo apt update sudo apt install nginx mariadb-server php php-fpm php-mbstring php-xml php-json php-mysql php-curl php-intl php-gd php-mbstring texlive imagemagick unzip -y
  1. Configure MariaDB:
sudo mysql_secure_installation sudo mysql -u root -p

Inside the MariaDB shell:

CREATE DATABASE wikidb; GRANT ALL PRIVILEGES ON wikidb.* TO 'wikiuser'@'localhost' IDENTIFIED BY 'password'; FLUSH PRIVILEGES; EXIT;
  1. Download and Configure MediaWiki:
cd /var/www/html wget https://releases.wikimedia.org/mediawiki/1.31/mediawiki-1.31.0.tar.gz tar xvf mediawiki-1.31.0.tar.gz mv mediawiki-1.31.0 mediawiki sudo chown -R www-data:www-data /var/www/html/mediawiki
  1. Configure Nginx: Create a new Nginx configuration file:
sudo nano /etc/nginx/conf.d/wiki.conf

Add the following content:

server { listen 80; server_name wiki.example.com; root /var/www/html/mediawiki; index index.php; error_log /var/log/nginx/mediawiki.error; access_log /var/log/nginx/mediawiki.access; location / { try_files $uri $uri/ /index.php; } location ~ \.php$ { fastcgi_pass unix:/run/php/php7.4-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; include snippets/fastcgi-php.conf; } location ~ /\.ht { deny all; } }

Test and restart Nginx:

sudo nginx -t sudo systemctl restart nginx
  1. Secure with Let's Encrypt: Install Certbot:
sudo apt install certbot python3-certbot-nginx -y

Obtain and install the SSL certificate:

sudo certbot --nginx -d wiki.example.com
  1. Finalize MediaWiki Installation: Open your browser and navigate to http://wiki.example.com to complete the MediaWiki setup through the web interface.

No comments:

Post a Comment