CentOS6配置Taiga

前端之家收集整理的这篇文章主要介绍了CentOS6配置Taiga前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

文章允许转载,请注明来源:@L_403_0@

背景

企业项目管理是一个比较复杂的事情,这个市场需求非常大,目前市面上也存在着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安装基本的依赖

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

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

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

安装postgresql-9.4

  1. #rpm -ivh http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm
  2. #sed -i 's/^gpgkey.*/&\nexclude=postgresql*/' /etc/yum.repos.d/CentOS-Base.repo
  3.  
  4. #yum -y install postgresql94 postgresql94-contrib postgresql94-server postgresql94-devel postgresql94-libs
  5. #service postgresql-9.4 initdb

设置验证方式为MD5

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

设置postgresql开机启动

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

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

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

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

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

将miniconda加入环境变量

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

source使配置生效

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

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

taiga-back配置

添加用户taiga并生成目录

  1. #adduser taiga
  2.  
  3. #DIR="/var/log/taiga /opt/taiga-back /opt/taiga-events"
  4. for NAME in $DIR
  5. do
  6. if [ ! -d $NAME ]; then
  7. mkdir $NAME
  8. chown taiga.taiga $NAME
  9. fi
  10. done

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

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

创建crond虚拟环境并安装pip

  1. $conda create --yes -n taiga python
  2. $source activate taiga
  3. $conda install --yes pip

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

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

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

  1. #cat > /opt/taiga-back/settings/local.py << EOF
  2. from .development import *
  3.  
  4. DATABASES = {
  5. 'default': {
  6. 'ENGINE': 'django.db.backends.postgresql',
  7. 'NAME': '$TAIGA_POSTGRES_BD',
  8. 'USER': '$TAIGA_POSTGRES_USER',
  9. 'PASSWORD': '$TAIGA_POSTGRES_PASSWORD'
  10. }
  11. }
  12.  
  13. MEDIA_URL = "http://example.com/media/"
  14. STATIC_URL = "http://example.com/static/"
  15. ADMIN_MEDIA_PREFIX = "http://example.com/static/admin/"
  16. SITES["front"]["scheme"] = "http"
  17. SITES["front"]["domain"] = "example.com"
  18. SITES["api"]["scheme"] = "http"
  19. SITES["api"]["domain"] = "example.com"
  20.  
  21. SECRET_KEY = "$TAIGA_SECRET_KEY"
  22.  
  23. DEBUG = False
  24. TEMPLATE_DEBUG = False
  25.  
  26. PUBLIC_REGISTER_ENABLED = True
  27.  
  28. DEFAULT_FROM_EMAIL = "no-reply@example.com"
  29. SERVER_EMAIL = DEFAULT_FROM_EMAIL
  30.  
  31. # Uncomment and populate with proper connection parameters
  32. # for enable email sending.
  33. EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
  34. EMAIL_USE_TLS = False
  35. EMAIL_USE_SSL = True
  36. EMAIL_HOST = "smtp.exmail.qq.com"
  37. EMAIL_HOST_USER = "taiga@example.com"
  38. EMAIL_HOST_PASSWORD = "password"
  39. EMAIL_PORT = 465
  40. EOF

修改文件所有者

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

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

  1. #su - taiga
  2. $source activate taiga
  3. $cd /opt/taiga-back
  4. $python manage.py migrate --noinput
  5. $python manage.py loaddata initial_user
  6. $python manage.py loaddata initial_project_templates
  7. $python manage.py collectstatic --noinput
  8. $exit //退出taiga用户

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

安装circus和gunicorn

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

  1. #conda install --yes pip
  2. #pip install circus

此时执行

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

输出应该是

  1. # conda environments:
  2. #
  3. taiga /home/taiga/envs/taiga
  4. root * /usr/local/miniconda3

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

  1. #cat > /etc/circus.ini << EOF
  2. [circus]
  3. check_delay = 5
  4. endpoint = tcp://127.0.0.1:5555
  5. pubsub_endpoint = tcp://127.0.0.1:5556
  6. statsd = true
  7.  
  8. [watcher:taiga]
  9. working_dir = /opt/taiga-back
  10. cmd = gunicorn
  11. args = -w 3 -t 60 --pythonpath=. -b 127.0.0.1:8001 taiga.wsgi
  12. uid = taiga
  13. numprocesses = 1
  14. autostart = true
  15. send_hup = true
  16. stdout_stream.class = FileStream
  17. stdout_stream.filename = /var/log/taiga/gunicorn.stdout.log
  18. stdout_stream.max_bytes = 10485760
  19. stdout_stream.backup_count = 4
  20. stderr_stream.class = FileStream
  21. stderr_stream.filename = /var/log/taiga/gunicorn.stderr.log
  22. stderr_stream.max_bytes = 10485760
  23. stderr_stream.backup_count = 4
  24.  
  25. [env:taiga]
  26. PATH = \$PATH:/home/taiga/envs/taiga/bin
  27. TERM=rxvt-256color
  28. SHELL=/bin/bash
  29. USER=taiga
  30. LANG=en_US.UTF-8
  31. HOME=/home/taiga
  32. PYTHONPATH=/home/taiga/envs/taiga/lib/python3.6/site-packages
  33. EOF

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

  1. #cat > /etc/init/circus.conf << EOF
  2. start on runlevel [2345]
  3. stop on runlevel [016]
  4.  
  5. respawn
  6. exec /usr/local/miniconda3/bin/circusd /etc/circus.ini
  7. EOF

启动circus

  1. #initctl start circus

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

taiga-front配置

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

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

复制配置示例文件

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

修改配置文件

  1. #cat > /opt/taiga-front-dist/dist/conf.json << EOF
  2. {
  3. "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
  4. }
  5. EOF
配置Nginx反向代理
  1. server {
  2. listen 80;
  3. server_name example.com;
  4.  
  5. large_client_header_buffers 4 32k;
  6. client_max_body_size 50M;
  7. charset utf-8;
  8.  
  9. access_log /var/log/taiga/Nginx.access.log;
  10. error_log /var/log/taiga/Nginx.error.log;
  11.  
  12. # Frontend
  13. location / {
  14. root /opt/taiga-front-dist/dist/;
  15. try_files $uri $uri/ /index.html;
  16. }
  17.  
  18. # Backend
  19. location /api {
  20. proxy_set_header Host $http_host;
  21. proxy_set_header X-Real-IP $remote_addr;
  22. proxy_set_header X-Scheme $scheme;
  23. proxy_set_header X-Forwarded-Proto $scheme;
  24. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  25. proxy_pass http://127.0.0.1:8001/api;
  26. proxy_redirect off;
  27. }
  28.  
  29. # Django admin access (/admin/)
  30. location /admin {
  31. proxy_set_header Host $http_host;
  32. proxy_set_header X-Real-IP $remote_addr;
  33. proxy_set_header X-Scheme $scheme;
  34. proxy_set_header X-Forwarded-Proto $scheme;
  35. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  36. proxy_pass http://127.0.0.1:8001$request_uri;
  37. proxy_redirect off;
  38. }
  39.  
  40. # Static files
  41. location /static {
  42. alias /opt/taiga-back/static;
  43. }
  44.  
  45. # Media files
  46. location /media {
  47. alias /opt/taiga-back/media;
  48. }
  49.  
  50. # Taiga-events
  51. location /events {
  52. proxy_pass http://127.0.0.1:8887/events;
  53. proxy_http_version 1.1;
  54. proxy_set_header Upgrade $http_upgrade;
  55. proxy_set_header Connection "upgrade";
  56. proxy_connect_timeout 7d;
  57. proxy_send_timeout 7d;
  58. proxy_read_timeout 7d;
  59. }
  60. }

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

遇到的问题:

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

  1. '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中以下一行代码删除

  1. <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中

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

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

  1. one{one watcher} other{# watchers}

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

  1. #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

猜你在找的CentOS相关文章