Centos7.6配置Taiga

先決條件

sudo yum install -y epel-release

sudo yum update -y

sudo yum install -y firefox

sudo yum -y install nginx

安裝PostgreSQL

sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

sudo yum install -y postgresql95 postgresql95-devel postgresql95-contrib postgresql95-docs postgresql95-server

sudo /usr/pgsql-9.5/bin/postgresql95-setup initdb

systemctl start postgresql-9.5
systemctl enable postgresql-9.5

sudo su - postgres

createuser taiga
psql

ALTER USER taiga WITH ENCRYPTED password 'qweasdzxc';

CREATE DATABASE taiga OWNER taiga;

\q
exit

安裝Python 3

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

wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tar.xz

tar xf Python-3.6.3.tar.xz

cd Python-3.6.3
./configure --enable-optimizations --prefix=/usr

sudo make altinstall

sudo pip3.6 install virtualenv virtualenvwrapper
sudo pip3.6 install --upgrade setuptools pip

安裝Taiga後端

sudo useradd -s /bin/bash taiga
sudo su - taiga

mkdir -p ~/logs

git clone https://github.com/taigaio/taiga-back.git /usr/share/nginx/html/taiga/taiga-back

cd /usr/share/nginx/html/taiga/taiga-back
git checkout stable

echo "VIRTUALENVWRAPPER_PYTHON='/bin/python3.6'" >> ~/.bashrc
echo "source /usr/bin/virtualenvwrapper.sh" >> ~/.bashrc

source ~/.bashrc

mkvirtualenv -p /bin/python3.6 taiga
pip3.6 install --upgrade setuptools

cd /usr/share/nginx/html/taiga/taiga-back/
pip3.6 install -r requirements.txt

sudo chown -R taiga:taiga /usr/share/nginx/html/

python3.6 manage.py migrate --noinput
python3.6 manage.py loaddata initial_user
python3.6 manage.py loaddata initial_project_templates
python3.6 manage.py compilemessages
python3.6 manage.py collectstatic --noinput

nano /usr/share/nginx/html/taiga/taiga-back/settings/local.py

/usr/share/nginx/html/taiga/taiga-back/settings/local.py中填充如下內容

from .common import *

MEDIA_URL = "http://taiga.quaner.co/media/"
STATIC_URL = "http://taiga.quaner.co/static/"

SITES["front"]["scheme"] = "http"
SITES["front"]["domain"] = "taiga.quaner.co"

SECRET_KEY = "GMX4mE4uygyFtVMFRYbrjrh7q4JOe4U4EYMfuALh9BC487iEbe4Dgg5DGxk6GZdN"

DEBUG = False
PUBLIC_REGISTER_ENABLED = True

DEFAULT_FROM_EMAIL = "[email protected]"
SERVER_EMAIL = DEFAULT_FROM_EMAIL

#CELERY_ENABLED = True

EVENTS_PUSH_BACKEND = "taiga.events.backends.rabbitmq.EventsPushBackend"
EVENTS_PUSH_BACKEND_OPTIONS = {"url":"amqp://taiga:qweasdzxc@localhost:5672/taiga"}


# Uncomment and populate with proper connection parameters
# for enable email sending. EMAIL_HOST_USER should end by @domain.tld
#EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
#EMAIL_USE_TLS = False
#EMAIL_HOST = "localhost"
#EMAIL_HOST_USER = ""
#EMAIL_HOST_PASSWORD = ""
#EMAIL_PORT = 25
# Uncomment and populate with proper connection parameters
# for enable github login/singin.
#GITHUB_API_CLIENT_ID = "yourgithubclientid"
#GITHUB_API_CLIENT_SECRET = "yourgithubclientsecret"

關閉虛擬環境

deactivate

安裝前端

git clone https://github.com/taigaio/taiga-front-dist.git /usr/share/nginx/html/taiga/taiga-front-dist

cd /usr/share/nginx/html/taiga/taiga-front-dist
git checkout stable

sudo nano /usr/share/nginx/html/taiga/taiga-front-dist/dist/conf.json

​在/usr/share/nginx/html/taiga/taiga-front-dist/dist/conf.json中填充如下內容

{
    "api": "http://taiga.quaner.co/api/v1/",
    "eventsUrl": "ws://taiga.quaner.co/events",
    "eventsMaxMissedHeartbeats": 5,
    "eventsHeartbeatIntervalTime": 60000,
    "eventsReconnectTryInterval": 10000,
    "debug": true,
    "debugInfo": false,
    "defaultLanguage": "en",
    "themes": ["taiga"],
    "defaultTheme": "taiga",
    "publicRegisterEnabled": true,
    "feedbackEnabled": true,
    "privacyPolicyUrl": null,
    "termsOfServiceUrl": null,
    "maxUploadFileSize": null,
    "contribPlugins": [],
    "tribeHost": null, 
    "importers": [],
    "gravatar": true
}

配置馬戲團

exit

sudo pip3.6 install circus

sudo mkdir /etc/circus
sudo mkdir /etc/circus/conf.d
sudo mkdir /usr/share/nginx/html/taiga/logs
sudo touch /usr/share/nginx/html/taiga/logs/gunicorn.stdout.log
sudo touch /usr/share/nginx/html/taiga/logs/gunicorn.stderr.log

sudo nano /etc/circus/circus.ini

​在/etc/circus/circus.ini中填充如下內容

[circus]
check_delay = 5
endpoint = tcp://127.0.0.1:5555
pubsub_endpoint = tcp://127.0.0.1:5556
include = /etc/circus/conf.d/*.ini

sudo nano /etc/circus/conf.d/taiga.ini

​在/etc/circus/circus.ini中填充如下內容

[watcher:taiga]
working_dir = /usr/share/nginx/html/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 = /usr/share/nginx/html/taiga/logs/gunicorn.stdout.log
stdout_stream.max_bytes = 10485760
stdout_stream.backup_count = 4
stderr_stream.class = FileStream
stderr_stream.filename = /usr/share/nginx/html/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.6/site-packages
​
sudo nano /etc/systemd/system/circus.service

/etc/systemd/system/circus.service中填充如下內容

[Unit]
Description=Circus process manager
After=syslog.target network.target nss-lookup.target

[Service]
Type=simple
ExecReload=/usr/bin/circusctl reload
ExecStart=/usr/bin/circusd /etc/circus/circus.ini
Restart=always
RestartSec=5

[Install]
WantedBy=default.target

賦予權限

# sudo chmod -R 777 /home/taiga/

sudo systemctl start circus
sudo systemctl enable circus

circusctl status

將Nginx安裝爲反向代理

sudo nano /etc/nginx/conf.d/taiga.conf

/etc/nginx/conf.d/taiga.conf中填充如下內容

server { 
    listen 80;
    server_name taiga.quaner.co;
    
    large_client_header_buffers 4 32k;
    client_max_body_size 50M;
    charset utf-8;
   
    # Frontend
    location / {
        root /usr/share/nginx/html/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://127.0.0.1:8001/api;
        proxy_redirect off;
    }
    
    # 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 /usr/share/nginx/html/taiga/taiga-back/static;
    }
    
    # Media files
    location /media {
        alias /usr/share/nginx/html/taiga/taiga-back/media;
    }
    
    # Events
    location /events {
        proxy_pass http://127.0.0.1:8888/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

sudo nginx -t

sudo systemctl restart nginx
sudo systemctl status nginx

sudo chown -R taiga:taiga /usr/share/nginx/html/
sudo chmod o+x /usr/share/nginx/html/


sudo systemctl stop firewalld.service
sudo systemctl disable firewalld.service

錯誤記錄

  1. 允許HTTPPD腳本和模塊使用TCP連接到網絡
sudo setsebool -P httpd_can_network_connect 1
  1. 上面一個錯誤主要出現的原因是selinux的開啓,所以如果出現take me home的情況,請將selinux進行關閉。防火牆也記得要關閉,這也是可能導致taiga無法訪問的原因之一。(關於這一點因爲能力不足,所以沒有辦法進行深入的解釋,等深入以後希望能有更好的解釋)

  2. 如果出現Nginx的Welcome To Nginx頁面可以訪問,但是本身頁面無法訪問的情況,我的解決辦法是將taiga的配置文件放入/usr/share/nginx/html/的下面。因爲既然Nginx的主頁可以訪問,就說明/usr/share/nginx/html/的下面是可以被Nginx訪問到的,所以在git克隆taiga-back和taiga-front-dist的時候選擇了放入/usr/share/nginx/html/下面。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章