Ubuntu Server

Overview

This chapter introduces the installation process for GROWI on Ubuntu Server 16.04 (Xenial). Installation on 14.04 and 18.04 have not been verified.

Software needed for Setup are listed below.

  • node.js 8.x (DO NOT USE 9.x)
  • npm 5.x or 6.x
  • yarn
  • MongoDB 3.x
  • (Option) Elasticsearch 5.x
  • (Option) systemd
  • (Option) Apache or nginx

Software listed as 'Optional' are not required, but in this document all are used, from construction of an environment using Apache or nginx as a reverse proxy for the full-text search feasible Growi, to simultaneously launching the host OS using systemd.

Installation for node.js 8.x & npm

Use the NodeSource repository

Download the Node.js installation script from https://deb.nodesource.com/. The working directory is the home directory.

$ cd ~
$ curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh

Run the retrieved script.

$ sudo bash nodesource_setup.sh

Now that node.js can be retrieved via apt-get, use the apt-get command to install.

$ sudo apt-get install nodejs

Since GROWI uses yarn for package installation, install the yarn command.

$ sudo npm install -g yarn

Once installation for Node.js, npm, yarn is completed, check the installed versions.

$ nodejs -v
v8.11.3
$ npm -v
5.6.0
$ yarn -v
1.9.2

Elasticsearch

Installation

Follow the Official Website to proceed installation. Here we make a few changes to install Elasticsearch 5.x

WARNING

This document is outdated. GROWI currently supports the most recent version of Elasticsearch 6.x (updated 05/2019)

First, install JDK8 to make Elasticsearch runnable.

$ sudo apt-get install openjdk-8-jdk

To install the package, import the Elasticsearch repository's GPG key.

$ wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

To allow installation using the apt command via https, install the apt-transport-https package.

$ sudo apt-get install apt-transport-https

Add the Elasticsearch repository.

$ echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list

Now Elasticsearch can be installed via apt-get. Install.

$ sudo apt-get update && sudo apt-get install elasticsearch

Once the installation is complete, specifiy the memory allocation pool size for Elasticsearch. If the usage is for individual use, 256MB should be enough for memory allocation. Make changes based on the scale of the team and the amount of pages.

$ sudo vim /etc/elasticsearch/jvm.options
# Before edit
-Xms1g
-Xmx1g

# After edit
-Xms256m
-Xmx256m

Once installation is completed, check the package version.

$ dpkg -l | grep elasticsearch
ii  elasticsearch                    5.6.10                                     all          Elasticsearch is a distributed RESTful search engine built for the cloud. Reference documentation can be found at https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html and the 'Elasticsearch: The Definitive Guide' book can be found at https://www.elastic.co/guide/en/elasticsearch/guide/current/index.html

Using the systemctl command, launch Elasticsearch.

$ sudo systemctl start elasticsearch

Enable the autoboot setting of elasticsearch

$ sudo systemctl enable elasticsearch

Check the status to verify it is running properly.

$ sudo systemctl status elasticsearch

Installation for Elasticsearch plugins needed for GROWI

We will install the Elasticsearch plugins shown below

First, search for the command used to install Elasticsearch plugins

$ dpkg -L elasticsearch | grep bin | grep plugin
/usr/share/elasticsearch/bin/elasticsearch-plugin

Using the command above, install both the analysis-kuromoji plugin and the analysis-icu plugin

# Installation for analysis-kuromoji
$ sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-kuromoji

# Installation for analysis-icu plugin
$ sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-icu

MongoDB

Installation

Follow the Official Website to proceed installation. In this section MongoDB 3.6 is used.

To start off, import the public key used by apt.

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5

Add the repository. Listed below are examples for Ubuntu 14.04 and Ubuntu 16.04.

Ubuntu 14.04

$ echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list

Ubuntu 16.04

$ echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list

Now that the repository has been added, install MongoDB.

$ sudo apt-get update && sudo apt-get install mongodb-server

Once installation is complete, check the package versions.

ii  mongodb-org                      3.6.6                                      amd64        MongoDB open source document-oriented database system (metapackage)
ii  mongodb-org-mongos               3.6.6                                      amd64        MongoDB sharded cluster query router
ii  mongodb-org-server               3.6.6                                      amd64        MongoDB database server
ii  mongodb-org-shell                3.6.6                                      amd64        MongoDB shell client
ii  mongodb-org-tools                3.6.6                                      amd64        MongoDB tools

Using the systemctl command, launch MongoDB.

$ sudo systemctl start mongod

Enable the autoboot setting of MongoDB.

$ sudo systemctl enable mongod

Check the status to verify it is running properly.

$ sudo systemctl status mongod

GROWI

Installation

Download the source code from https://github.com/weseek/growi, and check the latest stable version at https://github.com/weseek/growi/releases.

The installation procedure shown below will be carried out under /opt/growi.

$ sudo mkdir -p /opt/
$ cd /opt/
$ sudo git clone https://github.com/weseek/growi /opt/growi
$ cd /opt/growi

# Check the tags
$ sudo git tag -l
...
v3.1.7
v3.1.8
v3.1.8-RC
v3.1.8-RC2
v3.1.9
v3.2.0-RC4
...

# Use the latest version that doesn't have RC
$ sudo git checkout -b v3.1.9 refs/tags/v3.1.9

After cloning the source code, use the yarn command to install packages needed for GROWI.

$ cd /opt/growi
$ sudo yarn

Check Startup

Once installation for packages is completed, check the startup.

Here it is a requirement that MongoDB and Elasticsearch are running under the same hostname.

Rewrite MONGO_URI and ELASTICSEARCH_URI appropriate to the environment.

$ sudo \
MONGO_URI=mongodb://localhost:27017/growi \
ELASTICSEARCH_URI=http://localhost:9200/growi \
npm start

...
# Wait for the message below to appear
> growi@3.1.9 server:prod /opt/growi
> env-cmd config/env.prod.js node app.js

Access http://<hostname or ip address>:3000/ and check whether the initial setup page appears.

Setting autoboot using systemd

See "Autostart using systemd".

リバースプロキシの設定

ここでは、起動した GROWI に対してリバースプロキシを行うための設定例を記載します。

Apache

インストール

$ sudo apt-get update && sudo apt-get -y install apache2

必要なモジュールの有効化

proxy, proxy_http, proxy_wstunnel module をインストールします

$ sudo a2enmod proxy proxy_http proxy_wstunnel

リバースプロキシの設定例

ここではリバースプロキシに関する箇所を抜粋して記載しています。

<IfModule mod_ssl.c>
  <VirtualHost _default_:443>
    ...
    ###
    # reverse proxy to crowi
    # Header に Host: example.com を追加するため
    ProxyPreserveHost On
    # HTTPS利用時: Header に x-forwarded-proto: https を追加するため
    RequestHeader set x-forwarded-proto 'https'
    # Apache では static assets で 304 が返らないことがあるので ETag を無効化する
    <ifModule mod_headers.c>
            Header unset ETag
    </ifModule>
    FileETag None

    # socket.io の path を rewrite する
    RewriteEngine On
    RewriteCond %{REQUEST_URI}  ^/socket.io            [NC]
    RewriteCond %{QUERY_STRING} transport=websocket    [NC]
    RewriteRule /(.*) ws://localhost:3000/$1 [P,L]

    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/
    ...
  </VirtualHost>
</IfModule>

自動起動の設定

$ sudo systemctl enable apache2

Nginx のインストールと設定

インストール

$ sudo apt-get update && sudo apt-get -y install nginx

リバースプロキシの設定例

ここでは HTTPS を利用する設定例を記載しています。 <server> など<>で囲まれている箇所は、適宜環境に合わせて設定してください。

upstream growi {
    server localhost:3000;
}

map $http_upgrade $connection_upgrade {
    default Upgrade;
    ''      close;
}

server {
    listen 443 ssl spdy;
    server_name <server>;
    ssl_certificate <cert_file>;
    ssl_certificate_key <key_file>;

    location / {
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Port $server_port;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://growi;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_read_timeout 900s;
    }
}

server {
    listen 80;
    server_name <server>;
    return 301 https://$server_name$request_uri;
}

自動起動の設定

$ sudo systemctl enable nginx
Last Updated: 7/10/2019, 5:46:09 AM