XWiki Snap Guide

Last modified by Vedant Pol on 2022/09/26 08:59

Description

XWiki-jetty Snap

Based on the XWiki Demo package modified to be production ready. It includes all the Java connectors required for the supported databases. This is the current XWiki Snap (Other Snaps have been decommissioned).
Source

XWiki-base-Snap

This Snap is based on the XWiki War package.It also includes Tomcat9 and all the supported Java connectors. The following Snap has been retired. Source

XWiki-mysql-snap

This Snap is also based on the XWiki War package. The Snap includes Tomcat9, MySQL, and the MySQL java connector.The following Snap has also been discontinued. 
Source

Installation

 

You can download and install the snap from the Snapcraft Store
Generally for ubuntu users with preinstalled snapd can install it by using the following command:
sudo snap install xwiki  

Getting Started

To Start XWiki

After installing the snap you can start XWiki with the command
 sudo xwiki.start 
Sudo previliges are essential

To Stop XWiki

If an instance of XWiki is running, you can stop it with the command
sudo xwiki.stop 
Sudo previliges are essential

To upgrade XWiki

Just enter sudo snap refresh xwiki  ,it would automatically  update your snap and copy your permanent directory and config files.

All the config files and permanent directory data of the previous version is stored in var/snap/xwiki/<previous_revision>.(You can copy them manually if you desire)

Configuration

Configure your database

XWiki snap comes preconfigured with HSQL database . This database is not recomended for production enviorment.Refer to the following link for more information on HSQLDB(link). 

Install and configure the database you wish to use:

The permanent directory has been set to var/snap/xwiki/<revision>/data/
The WEB-INF folder can be found in var/snap/xwiki/<revision>/webapps/xwiki/WEB-INF/
All the configuration file changes are to be made in the following directory for it to take effect in the xwiki var/snap/xwiki/<revision>/

All the jdbc drivers have been already installed in `/var/snap/xwiki/<revision>/webapps/xwiki/WEB-INF/lib/`

Building XWiki snap

Prerequisites to build

You'll need to perform 3 mandatory steps to build the snap :

Run the following commands to install snapcraft and multipass after installing snapd :
sudo snap install snapcraft --classic
sudo snap install multipass

Building the snap

  • clone the repository
  • cd into xwiki-jetty
  • run snapcraft

This will build the xwiki_13.10.8_amd64.snap
 cd into the directory of the snap you would like to build 
 eg. cd into xwiki-base-snap folder to build xwiki-base-snap 

Installing the snap

Make sure you are in the directory where the snap is built
sudo snap install xwiki_13.10.8_amd64.snap --dangerous

  xwiki-base-snap and xwiki-mysql-snap has been depriciated. xwiki-jetty snap is the official snap.

Releasing new version of the snap (XWiki release manager)

To release a new version of XWiki snap is fairly simple 

  • First you would replace the `Source:` in xwiki part here with the newer zip file link.
  • Change the version name here .

Thats all you need to do if there are no major changes in the XWiki-jetty package .
Now you can simply build the snap following the above guide.

If there some other configuration or package changes :

To change the java version

  • First change the stage package to the desired java version package here.
  • Then rename the java folder from 11 to your desired version here
  • Change the cacerts and blacklisted.certs accordingly here
  • Change the java home variable folder here

Now build the snap to see if everything works as desired .

To add another java connector or replace already existing

  • add or replace the java connector in the scripts folder of the repository .
  • move the connector inside the lib/ folder .similar to this

Now build the snap to see if there are any errors.

Setting up the xwiki-base-snap mysql database (obsolete)

  The following snap functions are depriciated
  

  • Make sure you have mysql 5.7 or greater installed.
  • Start the MySQL server. You can do that in several ways. For example use mysqld console
  • Create the wiki database.
    mysql -u root -e "create database xwiki default character set utf8mb4 collate utf8mb4_bin"
  • Create the xwiki user with password xwiki
    mysql -u root -e "CREATE USER 'xwiki'@'localhost' IDENTIFIED BY 'xwiki'";
  • Give privileges to the xwiki user for accessing and creating databases (for the multi wiki support). Specifically, the xwiki users need permissions to be able to execute CREATE DATABASE, DROP SCHEMA, and then all CRUD operations on tables. Note that the command below should be tuned to be more restrictive as granting all permissions is not required:
    mysql -u root -e "grant all privileges on *.* to xwiki@localhost"
  • The mysql JDBC Driver JAR and hibernate.cfg.xml have already been configured for mysql in the snap
  • Restart the snap
    sudo snap restart xwiki.tomcat
  • now you can launch xwiki: http://localhost:8080/xwiki/bin/view/Main/

Setting up the xwiki-mysql-snap (obsolete)

This snap consist of three parts:

  • xwiki-14.4.1
  • tomcat-9.0.x
  • mysql-8

The building would be similar to xwiki-base-snap except the installation part:

install the snap in devmode:

sudo snap install xwiki_14.4.1_amd64.snap --devmode

Running the snap a system service (obsolete)

 

Running mysql as a system service requires root access, but the server itself should never run as root, so it drops privileges to a dedicated user. This user must own the server files and directories. Currently snapd blocks access to creating users and changing process user, so the only way to do this is to disable the restrictions by installing the snap with the devmode argument.

post installation steps:
sudo snap connect xwiki:process-control :process-control
xwiki.startup
xwiki.client -uroot -p

This should start the mysql server . Then follow the steps mentioned in Setting up the xwiki-base-snap mysql database section and your mysql would be ready .
now you can launch xwiki: http://localhost:8080/xwiki/bin/view/Main/

Files and directories (obsolete)

The first time you run mysql.startup, it will generate the following in $HOME/snap/xwiki/common (if run as root, /var/snap/xwiki/common is used instead):
- conf/my.cnf: Basic configuration file
- data/: Data directoriy
- files/: Default location for the secure-file-priv option
- log/: Location of error log
- run/: Location of sock and pid files

Get Connected