1. 程式人生 > >CentOS7上部署taiga專案管理軟體

CentOS7上部署taiga專案管理軟體

作者:waringid 


一、簡介

Taiga 是一個免費開源,而且功能非常強大的專案管理平臺,用於初創企業和敏捷開發團隊。提供一個簡單、漂亮的專案管理工具。Taiga 採用 Python Django 框架開發,前端基於 AngularJS 實現。

二、更新必要的元件及系統版本

  • 安裝必要的元件並更新系統

yum install -y gcc autoconf flex bison libjpeg-turbo-devel
yum install -y freetype-devel zlib-devel zeromq-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++
  • 安裝PostgreSQL 9.5

wget http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
rpm -ivh pgdg-centos95-9.5-2.noarch.rpm
yum install -y postgresql95-server postgresql95-devel postgresql95-contrib
export PATH=$PATH:/usr/pgsql-9.5/bin
  • 修改驗證方式為md5

vim /var/lib/pgsql/9.5/data/pg_hba.conf
postgresql95-setup initdb
systemctl start postgresql-9.5.service
  • 安裝Python 3.5.1

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

三、配置資料庫及使用者環境

  • 新建使用者及資料庫

useradd taiga
sudo -u postgres psql
CREATE DATABASE taiga;
CREATE USER taiga WITH PASSWORD 'J5brHrAXFLQSif0K';
GRANT ALL PRIVILEGES ON DATABASE taiga TO taiga;
\q
  • 配置pip環境

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

四、配置taiga-back

  • 下載內容

cd /home/taiga
git clone https://github.com/taigaio/taiga-back.git taiga-back
cd taiga-back/
git checkout stable
  • 配置python元件

sed -i -e '34s/^/#/ig' requirements.txt  
sed -i -e '34a git+https://github.com/Xof/django-pglocks.git' requirements.txt
pip3.5 install -r requirements.txt
chown -R taiga:taiga /home/taiga/
sed -i -e '1a #!/opt/python3.5/bin/python3.5' -e '1d' manage.py  
  • 初始化啟動配置

su taiga
cd /home/taiga/taiga-back
python3.5 manage.py migrate --noinput
python3.5 manage.py loaddata initial_user
python3.5 manage.py loaddata initial_project_templates
python3.5 manage.py loaddata initial_role
python3.5 manage.py compilemessages
python3.5 manage.py collectstatic –noinput
  • 配置檔案設定

vim /home/taiga/taiga-back/settings/local.py
from .development import *
from .common import *
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'taiga',
        'USER': 'taiga',
        'PASSWORD': 'youpassword',
        'HOST': '',
        'PORT': '',
    }
}
MEDIA_URL = "http://192.168.5.86/media/"
STATIC_URL = "http://192.168.5.86/static/"
ADMIN_MEDIA_PREFIX = "http://192.168.5.86/static/admin/"
SITES["front"]["scheme"] = "http"
SITES["front"]["domain"] = "192.168.5.86"
SECRET_KEY = "2k_DRTqCjy$&-Rul^C23Brf=DY80DLZCl7VF*xU$*ert7-6VccT"


  • 測試啟動狀態

python3.5 manage.py runserver 0.0.0.0:8000 --insecure


  • 安裝非同步訊息互動元件

cd /home/taiga/
git clone https://github.com/zeromq/libzmq.git libzmq
cd libzmq/
./autogen.sh
./configure --without-libsodium
make
make install
  • 安裝程序和socket監控工具circus

cd /home/taiga
git clone https://github.com/circus-tent/circus.git circus
cd /home/taiga/circus/
python3.5 setup.py install
ln -s /opt/python3.5/bin/circusd /usr/local/bin/circusd
ln -s /opt/python3.5/bin/gunicorn /usr/local/bin/gunicorn


  • 配置circus

mkdir -p /home/taiga/conf
vim circus.ini


[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


vim /usr/lib/systemd/system/circus.service


[Unit]
Description=circus
[Service]
ExecStart=/usr/local/bin/circusd /home/taiga/conf/circus.ini


ln -s '/usr/lib/systemd/system/circus.service' '/etc/systemd/system/circus.service'


  • 配置日誌內容

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


五、配置taiga-front

  • 安裝前端

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
systemctl start circus.service


  • 安裝nginx


vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1


yum install -y nginx


  • 配置nginx

vim /etc/nginx/conf.d/taiga.conf


server {
    listen 80 default_server;
    server_name _;

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

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

    # Frontend
    location / {
        root /opt/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://192.168.5.86: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://192.168.5.86:8001$request_uri;
        proxy_redirect off;
    }

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

    # Media files
    location /media {
        alias /opt/taiga/taiga-back/media;
    }
}


六、啟動測試

  • 啟動taiga

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


  • 啟動nginx

chown -R taiga:taiga /home/taiga/
chmod o+x /home/taiga/
systemctl restart nginx