CentOS6配置Taiga

文章允许转载,请注明来源:http://blog.csdn.net/feiniao8651/article/details/79244465

背景

企业项目管理是一个比较复杂的事情,这个市场需求非常大,目前市面上也存在着teambition,tower等平台,但是这些工具平台目前都是付费才能有完整的功能,免费版根本不能满足团队的需求。一番调研后,发现了Taiga这个强大的项目管理工具。
Taiga是免费开源的项目管理平台,适用于初创企业和敏捷开发。使用Django+AngularJS开发,据说Taiga没有自己的产品经理,如果真的是一群程序员开发出这样一个简单易用,页面又漂亮的产品,确实蛮厉害的。从Taiga官网可以看到,Taiga2015年评为最佳敏捷工具,2014年评为开源项目TOP10,2016年评为项目管理工具TOP11。
Taiga虽然有官方的付费版本,但是也可以部署到自己的服务器上。官方的教程只提供了在Ubuntu上部署的方法。如果是要往Ubuntu上部署,基本上按照官方教程就可以了,已经写的很详细了。但是往CentOS上部署的资料还是比较少,今天就详细介绍一下,同时也记录一下部署过程中,遇到的一些问题以及解决方法。

Taiga结构介绍

Taiga基本框架是分成两部分,分别是基于Django实现的taiga-back,和基于AngularJS实现的taiga-front。另外还有taiga-events等可选组件可以添加。
我们的部署过程主要围绕taiga-back和taiga-front的搭建进行。
环境:
CentOS 6.5(x64)
系统要求RAM >= 1GB
涉及到的关键组件及版本要求:
python(3.4+)
postgresql(>=9.4)
circus
nginx

taiga-back配置部署

安装基本依赖

安装过程涉及到python的虚拟环境,一定要区分清楚命令是应该是host环境执行,还是在虚拟环境执行。
下面的命令都是在host环境以root身份执行。
通过yum安装基本的依赖

#yum update -y
#yum groupinstall "Development Tools" -y
#yum install libxslt-devel libxml2-devel libXt-devel curl git tmux -y

设置配置用到的变量,变量设置后,只能在当前终端窗口有效,可以通过echo查看具体的值,如果要在其他终端中使用,可以把具体的值写入环境变量配置。

#TAIGA_POSTGRES_BD=taiga
#TAIGA_POSTGRES_USER=taiga
#TAIGA_POSTGRES_PASSWORD=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-20};echo;`
#TAIGA_SECRET_KEY=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-20};echo;`

安装postgresql-9.4

#rpm -ivh http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm
#sed -i 's/^gpgkey.*/&\nexclude=postgresql*/' /etc/yum.repos.d/CentOS-Base.repo

#yum -y install postgresql94 postgresql94-contrib postgresql94-server postgresql94-devel postgresql94-libs
#service postgresql-9.4 initdb

设置验证方式为MD5

#sed -i "/^host/s/ident/md5/g" /var/lib/pgsql/9.4/data/pg_hba.conf

设置postgresql开机启动

#/sbin/chkconfig --level 35 postgresql-9.4 on
#service postgresql-9.4 start

在postgresql中创建taiga用户及对应的数据库

#echo -e "$TAIGA_POSTGRES_PASSWORD\n$TAIGA_POSTGRES_PASSWORD\ny\n" | su - postgres -c "createuser --pwprompt $TAIGA_POSTGRES_USER"
#su - postgres -c "createdb $TAIGA_POSTGRES_BD -O $TAIGA_POSTGRES_USER"

安装python(这里使用conda来安装python及对应的依赖,conda可以相当于pip+virtualenv)

#wget --directory-prefix=/tmp http://repo.continuum.io/miniconda/Miniconda3-3.7.0-Linux-x86_64.sh
#bash /tmp/Miniconda3-3.7.0-Linux-x86_64.sh -b -p /usr/local/miniconda3

将miniconda加入环境变量

#cat > /etc/profile.d/miniconda.sh << EOF
if [[ \$PATH != */usr/local/miniconda3/bin* ]]
then
    export PATH=$PATH:/usr/local/miniconda3/bin:
fi
EOF

source使配置生效

#source /etc/profile.d/miniconda.sh

到这里基本的依赖已经装完了,接下来就要进入正题:taiga-back的部署。

taiga-back配置

添加用户taiga并生成目录

#adduser taiga

#DIR="/var/log/taiga /opt/taiga-back /opt/taiga-events"
for NAME in $DIR
do
if [ ! -d $NAME ]; then
   mkdir $NAME
   chown taiga.taiga $NAME
fi
done

切换到taiga用户同步taiga-back代码

#su - taiga
$git clone https://github.com/taigaio/taiga-back.git /opt/taiga-back
$cd /opt/taiga-back
$git checkout stable

创建crond虚拟环境并安装pip

$conda create --yes -n taiga python
$source activate taiga
$conda install --yes pip

在虚拟环境中使用pip安装依赖

$export PATH=$PATH:/usr/pgsql-9.4/bin/
$pip install -r requirements.txt
$exit   //安装完成后退出taiga用户

配置taiga-back,这里假设访问域名是example.com,如果没有域名,可以替换成ip地址

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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': '$TAIGA_POSTGRES_BD',
        'USER': '$TAIGA_POSTGRES_USER',
        'PASSWORD': '$TAIGA_POSTGRES_PASSWORD'
    }
}

MEDIA_URL = "http://example.com/media/"
STATIC_URL = "http://example.com/static/"
ADMIN_MEDIA_PREFIX = "http://example.com/static/admin/"
SITES["front"]["scheme"] = "http"
SITES["front"]["domain"] = "example.com"
SITES["api"]["scheme"] = "http"
SITES["api"]["domain"] = "example.com"

SECRET_KEY = "$TAIGA_SECRET_KEY"

DEBUG = False
TEMPLATE_DEBUG = False

PUBLIC_REGISTER_ENABLED = True

DEFAULT_FROM_EMAIL = "[email protected]"
SERVER_EMAIL = DEFAULT_FROM_EMAIL

# Uncomment and populate with proper connection parameters
# for enable email sending.
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_USE_TLS = False
EMAIL_USE_SSL = True
EMAIL_HOST = "smtp.exmail.qq.com"
EMAIL_HOST_USER = "[email protected]"
EMAIL_HOST_PASSWORD = "password"
EMAIL_PORT = 465
EOF

修改文件所有者

#chown taiga.taiga /opt/taiga-back/settings/local.py

切换到taiga用户,初始化taiga-back

#su - taiga
$source activate taiga
$cd /opt/taiga-back
$python manage.py migrate --noinput
$python manage.py loaddata initial_user
$python manage.py loaddata initial_project_templates
$python manage.py collectstatic --noinput
$exit   //退出taiga用户

通过以上命令就创建了一个账号名是”admin”,密码是”123123”的管理员用户,可以直接用这个账号从前端页面登录taiga。

安装circus和gunicorn

这时需要在root用户下通过conda来安装circus

#conda install --yes pip
#pip install circus

此时执行

#su - taiga -c "conda info -e"

输出应该是

# conda environments:
#
taiga                    /home/taiga/envs/taiga
root                  *  /usr/local/miniconda3

如果没有,第二个root用户项,就要确认一下自己是否切换错了用户。
修改circus配置文件

#cat > /etc/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 = /opt/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 = /var/log/taiga/gunicorn.stdout.log
stdout_stream.max_bytes = 10485760
stdout_stream.backup_count = 4
stderr_stream.class = FileStream
stderr_stream.filename = /var/log/taiga/gunicorn.stderr.log
stderr_stream.max_bytes = 10485760
stderr_stream.backup_count = 4

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

注意确认以上配置中的每一个路径是否有效,可能会略有差异。
设置circus启动脚本

#cat > /etc/init/circus.conf << EOF
start on runlevel [2345]
stop on runlevel [016]

respawn
exec /usr/local/miniconda3/bin/circusd /etc/circus.ini
EOF

启动circus

#initctl start circus

到这里,taiga-back已经配置完了,但是这只是把后台服务开起来了,我们还需要有前端界面才能使用taiga。

taiga-front配置

前端的配置就要简单多了,只要下载前端代码,修改配置文件,设置nginx反向代理三步即可。

下载代码
#cd /opt/
#git clone https://github.com/taigaio/taiga-front-dist.git
#cd taiga-front-dist
#git checkout stable
配置taiga-front

复制配置示例文件

#cp /opt/taiga-front-dist/dist/conf.example.json /opt/taiga-front-dist/dist/conf.json

修改配置文件

#cat > /opt/taiga-front-dist/dist/conf.json << EOF
{
    "api": "http://example.com/api/v1/",
    "eventsUrl": null,
    "eventsMaxMissedHeartbeats": 5,
    "eventsHeartbeatIntervalTime": 60000,
    "eventsReconnectTryInterval": 10000,
    "debug": true,
    "debugInfo": false,
    "defaultLanguage": "en",
    "themes": ["taiga"],
    "defaultTheme": "taiga",
    "publicRegisterEnabled": false,
    "feedbackEnabled": true,
    "privacyPolicyUrl": null,
    "termsOfServiceUrl": null,
    "maxUploadFileSize": null,
    "contribPlugins": [],
    "tribeHost": null,
    "importers": [],
    "gravatar": false
}
EOF
配置nginx反向代理
server {
    listen 80;
    server_name example.com;

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

    access_log /var/log/taiga/nginx.access.log;
    error_log /var/log/taiga/nginx.error.log;

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

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

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

    # Taiga-events
    location /events {
    proxy_pass http://127.0.0.1:8887/events;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_connect_timeout 7d;
    proxy_send_timeout 7d;
    proxy_read_timeout 7d;
    }
}

重启一下nginx 之后,在浏览器打开配置的域名或者ip,就能看到taiga的页面了。

遇到的问题:

1、报错“Can’t connect the postgreSQL with psycopg2”
这里是postgresql的安装路径默认在/tmp/下导致,可以在local.py 的DATABASE配置中添加

'HOST': '/tmp/'

2、“X-Frame-Options may only be set via an HTTP header sent along with a document. It may not be set inside < meta >”
将/opt/taiga-front-dist/dist/index.html中以下一行代码删除

<meta http-equiv="X-Frame-Options" content="deny">

3、选中文后报错“Invalid key one for argument total. Valid plural keys for this locale are other, and explicit keys like =0
这是对中文支持的问题,语言是英语的时候就没有这个报错。解决方法是修改/opt/taiga-front-dist/dist/v-1503987903941/locales/taiga/locale-zh-hans.json中

one{一个关注} other{# 个关注}

类似于这种格式的数据,将大括号中的数据替换成英文即可。例如,以上的代码应该改为

one{one watcher} other{# watchers}

这种修改一共有8处。修改完由于缓存的原因可能不是立即生效,可以尝试重启circus和nginx,并清理浏览器缓存。
4.选中文后报找不到zh-hans.js

#cp /opt/taiga-front-dist/dist/v-1503987903941/locales/moment-locales/zh-cn.js /opt/taiga-front-dist/dist/v-1503987903941/locales/moment-locales/zh-hans.js

参考:
Installing Taiga on CentOS 6 (x64)
TAIGA 部署
CentOS7上部署taiga项目管理软件
taiga安装手册
Can’t connect the postgreSQL with psycopg2

猜你喜欢

转载自blog.csdn.net/feiniao8651/article/details/79244465