LoginSignup
32
35

More than 5 years have passed since last update.

Taiga.IOをCentOS7にインストールした(ついでにスクリプトを作った)

Last updated at Posted at 2016-01-18

Taiga.IOって何?

アジャイルプロジェクトの管理ツール
かんばんとスクラムに対応
シンプルでUIが綺麗
https://taiga.io/
http://qiita.com/kgmyshin/items/2ac2ad7e6be8425ec60e

youtubeのチュートリアル
https://www.youtube.com/playlist?list=PLgsasMWN5JssgHHHHI50xkz_kzXg-dElt

参考

インストールしたもの

  • PostgreSQL 9.5
  • Python 3.5.2
  • taiga-back
  • taiga-front
  • nginx 1.10.0
  • Circus 0.14.0

本当に最小限で動くだけ

スクリプト

https://gist.github.com/skliber/50e7f389407d3de25b0f
黒魔術が多いがとりあえずできた

使い方

  1. スクリプト中のYOURIPという文字列を自分のIPに置き換える
    sed -i -e 's/YOURIP/192.168.x.x/g' setup-taiga-centos.sh

  2. ルートになってsourceコマンドで実行
    source setup-taiga-centos.sh

解説

1. yum

必要なものをまとめて入れておく
libzmqを入れるため、epelリポジトリを追加

yum install -y epel-release

yum install -y gcc autoconf flex bison libjpeg-turbo-devel
yum install -y freetype-devel zlib-devel zeromq3-devel gdbm-devel ncurses-devel
yum install -y automake libtool libffi-devel curl git tmux
yum install -y libxml2-devel libxslt-devel
yum install -y wget openssl-devel gcc-c++

2. PostgreSQL 9.5

PostgreSQL 9.5をインストールした後、dbの初期設定を行って起動する

wget http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-3.noarch.rpm
rpm -ivh pgdg-centos95-9.5-3.noarch.rpm
yum install -y postgresql95-server postgresql95-devel postgresql95-contrib
export PATH=$PATH:/usr/pgsql-9.5/bin
postgresql95-setup initdb
systemctl start postgresql-9.5.service

3. Python 3.5.2

Taiga.IOにはPython3.4以上が必要だが、CentOSのリポジトリにはないので、最新版をソースからインストールする
今回はインストール先を/opt/python3.5にした

wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz
tar xvf Python-3.5.2.tar.xz
cd Python-3.5.2/
./configure --prefix=/opt/python3.5
make
make install
export PATH=$PATH:/opt/python3.5/bin

4. PostgreSQL Taiga.IO用DB設定

黒魔術cd /homeでユーザーpostgresがコマンドを実行できる場所へ移動して、
ユーザーとデータベースを作る

cd /home
su postgres -c "createuser taiga"
su postgres -c "createdb taiga -O taiga"

5. virtualenvとvirtualenvwrapperのインストール

これらはPythonの固有環境を作ったり管理したりするものらしい
http://qiita.com/caad1229/items/325ca5c8ad198b0ebce7
http://qiita.com/_rdtr/items/5f3a9a9e2cb5a24f284e

mkvirtualenvコマンドが成功すると自動的に固有環境に入ってしまい、
あとで困るのでdeactivateで抜けておく
え?環境作った意味は?
あーあー聞こえない

pip3.5 install virtualenv virtualenvwrapper
VIRTUALENVWRAPPER_PYTHON=/opt/python3.5/bin/python3.5
source /opt/python3.5/bin/virtualenvwrapper.sh
mkvirtualenv -p /opt/python3.5/bin/python3.5 taiga
deactivate

6. taiga-back

最初にユーザーtaigaを追加する
Taiga.IOの主要ディレクトリは/home/taiga/以下に展開される

taiga-backはstable版をチェックアウト

adduser taiga
cd /home/taiga
git clone https://github.com/taigaio/taiga-back.git taiga-back
cd taiga-back/
git checkout stable

6.1. requirements.txt

taiga-backのrequirements.txtにはタグつきのgitアドレスがあるが、
どうもこのタグが今githubに存在しないようで、そのままインストールしようとすると失敗する
なので、sedコマンドで成功するアドレスを追記してからインストールする

sed -i -e '34a git+https://github.com/Xof/django-pglocks.git' requirements.txt

pip3.5 install -r requirements.txt

6.2. 所有者を直す+コードの微修正

/home/taiga/taiga-back/ディレクトリをルートで作成しているので、
ホームディレクトリ以下の所有者を直す
manage.pyはユーザーtaigaで実行する必要があるので、直さないと操作ができない

また、CentOS7にはPython2がディフォルトでインストールされており、
manage.pyをそのまま起動するとPython2で起動してしまって都合が悪い
sedコマンドでPython3.5を使うように修正する

chown -R taiga:taiga /home/taiga/

sed -i -e '1a #!/opt/python3.5/bin/python3.5' -e '1d' manage.py

7. taiga-backの初期設定

YOURIPの部分を「localhost」や「127.0.0.1」にすると、
自分からしかアクセスできなくなるので注意
ドメイン名かグローバルIPかプライベートIPを設定すると良さそう
参照:https://github.com/taigaio/taiga-scripts/issues/10

su taiga -c "python3.5 manage.py migrate --noinput"
su taiga -c "python3.5 manage.py loaddata initial_user"
su taiga -c "python3.5 manage.py loaddata initial_project_templates"
su taiga -c "python3.5 manage.py loaddata initial_role"
su taiga -c "python3.5 manage.py compilemessages"
su taiga -c "python3.5 manage.py collectstatic --noinput"

cat > /home/taiga/taiga-back/settings/local.py << EOF
from .development import *
from .common import *

MEDIA_URL = "http://YOURIP/media/"
STATIC_URL = "http://YOURIP/static/"
ADMIN_MEDIA_PREFIX = "http://YOURIP/static/admin/"
SITES["front"]["scheme"] = "http"
SITES["front"]["domain"] = "YOURIP"

SECRET_KEY = "theveryultratopsecretkey"

DEBUG = False
TEMPLATE_DEBUG = False
PUBLIC_REGISTER_ENABLED = True

DEFAULT_FROM_EMAIL = "no-reply@example.com"
SERVER_EMAIL = DEFAULT_FROM_EMAIL
EOF

8. taiga-front

設定用のjsonを作る必要がある
conf.example.jsonに自分のIPを設定してそのままコピーする

cd /home/taiga
git clone https://github.com/taigaio/taiga-front-dist.git taiga-front-dist
cd taiga-front-dist/
git checkout stable
cd dist/
sed -e 's/localhost/YOURIP/' conf.example.json > conf.json

9. Circus

pipでCircusをインストールする

cd /home/taiga
pip3.5 install circus

mkdir -p /home/taiga/conf
cat > /home/taiga/conf/circus.ini << EOF
[circus]
check_delay = 5
endpoint = tcp://127.0.0.1:5555
pubsub_endpoint = tcp://127.0.0.1:5556
statsd = true

[watcher:taiga]
working_dir = /home/taiga/taiga-back
cmd = gunicorn
args = -w 3 -t 60 --pythonpath=. -b 127.0.0.1:8001 taiga.wsgi
uid = taiga
numprocesses = 1
autostart = true
send_hup = true
stdout_stream.class = FileStream
stdout_stream.filename = /home/taiga/logs/gunicorn.stdout.log
stdout_stream.max_bytes = 10485760
stdout_stream.backup_count = 4
stderr_stream.class = FileStream
stderr_stream.filename = /home/taiga/logs/gunicorn.stderr.log
stderr_stream.max_bytes = 10485760
stderr_stream.backup_count = 4

[env:taiga]
PATH = /home/taiga/.virtualenvs/taiga/bin:$PATH
TERM=rxvt-256color
SHELL=/bin/bash
USER=taiga
LANG=en_US.UTF-8
HOME=/home/taiga
PYTHONPATH=/home/taiga/.virtualenvs/taiga/lib/python3.5/site-packages
EOF

mkdir -p /home/taiga/logs
touch /home/taiga/logs/gunicorn.stdout.log
touch /home/taiga/logs/gunicorn.stderr.log

10. Systemd用にCircusの設定ファイルを作る

CircusはSystemd用の設定ファイルを作ってくれない
仕方がないので自作する

cat > /usr/lib/systemd/system/circus.service << EOF
[Unit]
Description=circus

[Service]
ExecStart=/usr/local/bin/circusd /home/taiga/conf/circus.ini
EOF
ln -s '/usr/lib/systemd/system/circus.service' '/etc/systemd/system/circus.service'

11. Circus起動

先ほど作った設定ファイルを元に起動する

ln -s /root/.virtualenvs/taiga/bin/circusd /usr/local/bin/circusd
systemctl start circus.service

12. nginx

リポジトリを追加して新しめのものが入るようにする
Taiga.IO用の設定を行って起動する

cat > /etc/yum.repos.d/nginx.repo << 'EOF'
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
EOF
yum install -y nginx

cat > /etc/nginx/conf.d/taiga.conf << 'EOF'
server {
    listen 80 default_server;
    server_name _;

    large_client_header_buffers 4 32k;
    client_max_body_size 50M;
    charset utf-8;

    access_log /home/taiga/logs/nginx.access.log;
    error_log /home/taiga/logs/nginx.error.log;

    # Frontend
    location / {
        root /home/taiga/taiga-front-dist/dist/;
        try_files $uri $uri/ /index.html;
    }

    # Backend
    location /api {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://YOURIP:8001/api;
        proxy_redirect off;
    }

    # Django admin access (/admin/)
    location /admin {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://YOURIP:8001$request_uri;
        proxy_redirect off;
    }

    # Static files
    location /static {
        alias /home/taiga/taiga-back/static;
    }

    # Media files
    location /media {
        alias /home/taiga/taiga-back/media;
    }
}
EOF
systemctl restart nginx

13. 黒魔術

何度目かわからない黒魔術
/home/taiga/の所有者を直してOtherに実行権をつける
実行権を付けないとnginxがPermission deniedの500エラーを返す

chown -R taiga:taiga /home/taiga/
chmod o+x /home/taiga/

14. Taiga.IOのバックエンドを起動

ユーザーtaigaのバックグラウンドで起動する
0.0.0.0:8000を付けないと開発マシンからしかアクセスできないらしい
http://masasuzu.hatenablog.jp/entry/20100731/1280588504

su taiga -c "python3.5 /home/taiga/taiga-back/manage.py runserver 0.0.0.0:8000 &"

end. ブラウザでアクセス

最後のコマンドが成功すればポート8000番をListenし始めるはず
nginxがポート80番で待っているので、自分のIPにそのままアクセスすれば使えるようになっている
初期ユーザー名:admin
パスワード:123123

余談:なんでCentOSなんだ、Ubuntuじゃダメだったのか

本当は公式が用意しているスクリプトをUbuntuで叩けばすぐに使えるようになる
だが、私はずっとCentOSと共に生きてきたのでUbuntuを使う気にはならなかった
3日ぐらい延々とはまって挫折しかけたが、何とかなったので良しとする

32
35
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
32
35