Installing MediaWiki on Arch Linux with Nginx and SQLite

From GlassTTY
Jump to: navigation, search

This article details how to install MediaWiki on Arch Linux using the Nginx web server and SQLite database. For setting up a Mediawiki Droplet on digital ocean see Configuring a Digital Ocean MediaWiki Droplet.

MediaWiki

Install MediaWiki with the following command

   pacman -S mediawiki

Install the thumbnail rendering

   pacman -S imagemagick

Set up the folders for the data

   cd /usr/share/webapps
   mkdir data
   chgrp http data
   chmod g+w data

Sqlite

Install SQLite with the command

   pacman -S sqlite

PHP

Install PHP with acpu object caching, SQLite driver, thumbnail, Unicode and fast CGI options.

   pacman -S php
   pacman -S php-apcu
   pacman -S php-sqlite
   pacman -S php-gd
   pacman -S php-intl
   pacman -S php-fpm
   

Edit /etc/php/php.ini and ensure the MediaWiki folder (/var/lib/mediawiki/) is included e.g.

   open_basedir = /srv/http/:/home/:/tmp/:/usr/share/webapps/:/var/lib/mediawiki/

Also in /etc/php/php.ini, uncomment the following lines: (in the Dynamic Extensions section)

   extension=gd.so
   extension=intl.so
   extension=iconv.so
   extension=pdo_sqlite.so

Set the session path

   session.save_path = "/var/lib/php/sessions"
   

Create the directory if it doesn't exist and then restrict its permissions:

   # mkdir -p /var/lib/php/sessions/
   # chown http:http /var/lib/php/sessions
   # chmod go-rwx /var/lib/php/sessions

Enable ACPU by uncommenting the following line in /etc/php/conf.d/apcu.ini,

   extension=apcu.so
       

Nginx (Web Server)

Install with

   pacman -S nginx
   

Edit the /etc/nginx/nginx.conf file to configure the server. The value for worker_processes ultimately defines how many connections nginx will accept and how many processors it will be able to make use of. Generally, making it the number of hardware threads in your system is a good start.

Start and enable the service.

   systemctl start nginx.service
   systemctl enable nginx.service

To get MediaWiki working with Nginx, create the /etc/nginx/mediawiki.conf file as follows;

   location / {
      index index.php;
      try_files $uri $uri/ @mediawiki;
   }
   location @mediawiki {
      rewrite ^/(.*)$ /index.php;
   }
   location ~ \.php5?$ {
      include /etc/nginx/fastcgi_params;
      fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
      fastcgi_index index.php5;
      fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      try_files $uri @mediawiki;
   }
   location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
      try_files $uri /index.php;
      expires max;
      log_not_found off;
   }
   # Restrictions based on the .htaccess files
   location ^~ ^/(cache|includes|maintenance|languages|serialized|tests|images/deleted)/ {
      deny all;
   }
   location ^~ ^/(bin|docs|extensions|includes|maintenance|mw-config|resources|serialized|tests)/ {
      internal;
   }
   location ^~ /images/ {
      try_files $uri /index.php;
   }
   location ~ /\. {
      access_log off;
      log_not_found off; 
      deny all;
   }


Restart/Start the services.

   systemctl start php-fpm
   systemctl enable php-fpm
   
   systemctl stop nginx.service    
   systemctl start nginx.service

Navigate to http://<local ip>/mediawiki to install. Add the generated LocalSettings.php file to /usr/share/webapps/mediawiki.

Create a logo 160px x 160px and copy it to the /usr/share/webapps/mediawiki directory. and set the logo in th LocalSettings.php config file, e.g.

   $wgLogo = "$wgResourceBasePath/logo.png";

Google Analytics

See Adding Google Analytics to MediaWiki.