admin1

Admin

admin1admin@example.com

GROWI構築ノウハウ

https://note.com/funmylife/n/n0228b233d4b1  を参照して構築した。

0. 構築環境

以下環境にて構築成功

hogehoge piyopiyo

ほほほほほ

・ホストPC:Windows 10 Home(64bit)V2004 ・Vagrant 2.2.10 ・VirtualBox 6.1.14 ・ゲストPC(仮想PC):Ubuntu 18.04.2 LTS(bento/ubuntu-18.04) ・Docker version 19.03.13, build 4484c46d9d ・docker-compose 1.24.0-rc1

1. Windows10の仮想化をオフにする

windowsの機能を開く

・LINUX用windowsサブシステム ・Windowsハイパーバイザープラットフォーム ・仮想マシンプラットフォーム

以上の機能をオフにしておく

2. Vargrantの導入

以下から最新版をダウンロード。ダウンロード後はexeをクリックし順当にすすめる

Vargrant公式サイト 

3. VirtualBoxの導入

以下から最新版をダウンロード

VirtualBox公式サイト 

4. Vagrant+VirtualBoxでゲストPC(仮想PC)を作る

①ホスト側PCにVagrant作業ディレクトリを作成する

Cドライブの直下にvagrant\growiフォルダを作成

②コマンドプロンプトからVagrantイメージを作成する

以下コマンドを順に打っていく。まずubuntu-18.04イメージを取得し、vagrant upコマンドを発行することで ゲストPCにubuntuがインストールされ使用できる状態になる。 vagrant sshでログインできる。

C:\vagrant\growi> vagrant init bento/ubuntu-18.04 C:\vagrant\growi> vagrant up C:\vagrant\growi> vagrant ssh

5. ゲストPC(仮想PC)の環境設定

注意) ここから先はゲストPC側の設定となる

vagrant sshでログイン後、以下コマンドを順次打っていく

vagrant@vagrant:~$ sudo apt update && sudo apt upgrade -y vagrant@vagrant:~$ sudo locale-gen ja_JP.UTF-8 vagrant@vagrant:~$ sudo localectl set-locale LANG=ja_JP.UTF-8 LANGUAGE="ja_JP:ja" vagrant@vagrant:~$ exit #いったんゲストPCから抜ける D:\vagrant\growi> vagrant ssh vagrant@vagrant:~$ echo $LANG ja_JP.UTF-8 vagrant@vagrant:~$ sudo dpkg-reconfigure tzdata #[アジア]-[東京]を選択しましょう vagrant@vagrant:~$ exit #いったんゲストPCから抜ける D:\vagrant\growi> vagrant reload #ゲストPCを再起動 D:\vagrant\growi> vagrant ssh

6. ゲストPC(仮想PC)に Dockerインストール

注意) Windows10の仮想化をオフにしないと、ここでDokerをインストールできない

https://docs.docker.com/engine/install/ubuntu/ を参照すると良い 

新しいホストマシンにDockerEngineを初めてインストールする前に、Dockerリポジトリを設定する必要がある。 その後、リポジトリからDockerをインストールして更新できる。

①まずリポジトリを設定する

$ sudo apt-get update $ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common

②Dockerの公式GPGキーを追加する

$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

③指紋を確認する

$ sudo apt-key fingerprint 0EBFCD88

また、以下コマンドを実行する。これを行わないとdockerをダウンロードできない。

$ sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable"

④dokerパッケージをインストールする

$ sudo apt-get update $ sudo apt-get install docker-ce docker-ce-cli containerd.io

⑤インストール後の初期設定を行う

以下コマンドを順次実行する

vagrant@vagrant:~$ docker -v Docker version 18.06.2-ce, build 6d37f41 vagrant@vagrant:~$ sudo usermod -aG docker $USER #root権限なしで実行する vagrant@vagrant:~$ exit #いったんゲストPCから抜ける D:\vagrant\growi> vagrant ssh vagrant@vagrant:~$ groups #dockerに所属していることを確認する

7. ゲストPCに Docker Composeインストール

以下コマンドを実行する

vagrant@vagrant:~$ sudo curl -L https://github.com/docker/compose/releases/download/1.24.0-rc1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose vagrant@vagrant:~$ sudo chmod +x /usr/local/bin/docker-compose vagrant@vagrant:~$ docker-compose -v docker-compose version 1.24.0-rc1, build 0f3d4dda

8. ゲストPCに GROWIインストール

ここでようやくGROWIのインストールが行える。
gitコマンドを使用してGROWIをダウンロードしたあと、docker-compose.ymlを編集する

vagrant@vagrant:~$ git clone https://github.com/weseek/growi-docker-compose.git growi vagrant@vagrant:~$ cd growi vagrant@vagrant:~$ vi docker-compose.yml

以下を変更する。ポートと添付ファイル格納先の変更である。ポート3000FILE_UPLOAD=localを有効にする

※FILE_UPLOAD=localの場合、添付ファイルの保存先はgrowi_app/data/uploads/attacmentとなる

ports: #- 127.0.0.1:3000:3000 # localhost only by default - 3000:3000 # ← modified environment: - MONGO_URI=mongodb://mongo:27017/growi - ELASTICSEARCH_URI=http://elasticsearch:9200/growi - PASSWORD_SEED=changeme # - FILE_UPLOAD=mongodb # activate this line if you use MongoDB GridFS rather than AWS - FILE_UPLOAD=local # activate this line if you use local storage of server rather than AWS # - MATHJAX=1 # activate this line if you want to use MathJax # - PLANTUML_URI=http:// # activate this line and specify if you use your own PlantUML server rather than public p

9. GROWIをビルド

順調に行けば、Express server is listening on port 3000のメッセージが出る。これがビルドフィニッシュの証拠となる。

vagrant@vagrant:~$ docker-compose up #ひたすらログが流れて app_1 ・・・ : [production] Express server is listening on port 3000 #↑が表示されれば完了した

ただし、これではlocalhost:3000でURLを打っても表示されない。

10. Vagrantのポートフォワードの設定

このアプリはデフォルトで3000番ポートで待ち受けている。
ホストPCの12345番ポート(ここは任意)をゲストPCの3000番ポートにポートフォワード設定させる。

①Ctrl+Cでアプリを止め、ゲストPCを抜けVagrantfileを弄る。以下のように設定。

# Create a forwarded port mapping which allows access to a specific port # within the machine from a port on the host machine. In the example below, # accessing "localhost:8080" will access port 80 on the guest machine. # NOTE: This will enable public access to the opened port config.vm.network "forwarded_port", guest: 3000, host: 12345

②ゲストPCを再起動し、GROWIを起動させる

D:\vagrant\growi> vagrant reload D:\vagrant\growi> vagrant ssh vagrant@vagrant:~$ cd growi vagrant@vagrant:~$ docker-compose start Starting mongo ... done Starting elasticsearch ... done Starting app ... done

http://localhost:12345にアクセス

以下の画面がでれば構築完了

11. インデックス再構築

もしコピー環境を作っているのであれば、管理画面よりインデックスの再構築が必要。 これをやらないと全文検索ができない。