腾飞基因项目 安装配置文档-Ubuntu版

腾飞基因项目 安装配置文档-Ubuntu版

一、buildout Plone 生产环境

1、创建用户组,用户,并为该用户账号授权sudo
以root身份登陆系统

root@ubuntu1804:~# adduser --home /home/plone plone plone

 

添加用户demo到sudo组

root@ubuntu1804:~# usermod –aG sudo plone


2、用plone用户登陆系统,安装Plone依存的系统库

plone@ubuntu1804:~$ sudo apt-get update
plone@ubuntu1804:~$ sudo apt-get install python-setuptools python-dev build-essential libssl-dev libxml2-dev libxslt1-dev libbz2-dev libjpeg62-dev zlib1g-dev libreadline-dev wv poppler-utils libssl-dev libffi-dev python-matplotlib python-gtk2 fonts-wqy-microhei fonts-wqy-zenhei  libreoffice apache2 varnish p7zip python-docutils libncurses5-dev libncursesw5-dev
plone@ubuntu1804:~$ sudo apt-get install libreoffice-help-common

  varnish 我们采用自编译版本,禁止掉系统 varnish:

plone@ubuntu1804:~$ sudo systemctl stop varnish
plone@ubuntu1804:~$ sudo systemctl disable varnish

3、在用户主目录下,创建目录workspace,下载并编译安装python2.7.x最新版,本文是python 2.7.15

plone@ubuntu1804:~$ mkdir ~/workspace
plone@ubuntu1804:~$ mkdir workspace/downloads plone@ubuntu1804:~$ cd workspace/downloads

去到python.org官方网站下载:

 

plone@ubuntu1804:~/workspace/downloads$ wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz

解压缩,编译安装python2.7.15

plone@ubuntu1804:~/workspace/downloads$ tar -zxvf Python-2.7.15.tgz
plone@ubuntu1804:~/workspace/downloads$ cd Python-2.7.15
plone@ubuntu1804:~/workspace/downloads/Python-2.7.15$ ./configure --prefix=/home/plone/workspace/python2715 --enable-unicode=ucs4 --enable-optimizations
plone@ubuntu1804:~/workspace/downloads/Python-2.7.15$ make
plone@ubuntu1804:~/workspace/downloads/Python-2.7.15$ make install

4、下载get-pip.py,用python2.7.15 安装pip

plone@ubuntu1804:~/workspace/downloads$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
plone@ubuntu1804:~/workspace/downloads$ cd ~/workspace/python2715/

给python2715安装pip

plone@ubuntu1804:~/workspace/python2715$ bin/python2 ~/downloads/get-pip.py


5、克隆gene.buildout生产站点配置项目到用户主目录workspace

plone@ubuntu1804:~/workspace/python2715$ cd ~/workspace
plone@ubuntu1804:~/workspace$ git clone -b master --single-branch  https://github.com/Ascendasgenomics/gene.buildout.git gene


6、用pip2 安装virtualenv,并创建python虚拟环境

plone@ubuntu1804:~/workspace$ cd ~/workspace/python2715/
plone@ubuntu1804:~/workspace/python2715$ bin/pip2 install virtualenv
plone@ubuntu1804:~/workspace/python2715$ bin/virtualenv /home/plone/workspace/gene

7、激活虚拟环境

plone@ubuntu1804:~/workspace/python2715$ cd ~/workspace/gene
plone@ubuntu1804:~/workspace/gene$ source bin/activate

8、编译安装部分三方模块到虚拟环境python路径,包括但不限于zc.buildout、setuptools等

(gene) plone@ubuntu1804:~/workspace/gene$ 
(gene) plone@ubuntu1804:~/workspace/gene$ pip2 install --trusted-host mirrors.aliyun.com -i http://mirrors.aliyun.com/pypi/simple -r requirements-5-1.txt


9、建立buildou缓存目录,运行buildout配置命令:

(gene) plone@ubuntu1804:~/workspace/gene$ cd ..
(gene) plone@ubuntu1804:~/workspace$ tar -zxvf downloads/build_eggs.tar.gz

注意:解压缩后会生成一个名为.buildout的目录,默认是隐藏的。

 

10、释放开发包到 /home/plone/workspace/gene目录

(gene) plone@ubuntu1804:~/workspace$ cd gene
(gene) plone@ubuntu1804:~/workspace/gene$ tar -zxvf ../downloads/src.tar.gz

运行buildout

(gene) plone@ubuntu1804:~/workspace/gene$ bin/buildout -Nvvv -c deploy_haproxy.cfg

10、通过supervisor启动各服务进程

(gene) plone@ubuntu1804:~/workspace/gene$ sudo bin/supervisord

检测各服务进程

(gene) plone@ubuntu1804:~/workspace/gene$ bin/supervisorctl status

二、配置apache2

启用某些模块

(gene) plone@ubuntu1804:~$ sudo a2enmod rewrite
(gene) plone@ubuntu1804:~$ sudo a2enmod proxy
(gene) plone@ubuntu1804:~$ sudo a2enmod expires
(gene) plone@ubuntu1804:~$ sudo a2enmod deflate

在 /etc/apache2/site-available下增加文件demo.gene.org.conf,这个用于主站日常访问

(gene) plone@ubuntu1804:~$ cd /etc/apache2/site-available/
(gene) plone@ubuntu1804:/etc/apache2/site-available$ sudo touch demo.gene.org.conf
(gene) plone@ubuntu1804:/etc/apache2/site-available$ sudo vi demo.gene.org.conf

输入如下内容:

<VirtualHost *:80>
<Proxy *>
Allow from www.gene.org
</Proxy>
ServerName www.gene.org
ServerAlias gene.org
RewriteEngine on
RewriteRule ^(.*)$ http://localhost:8581/VirtualHostBase/http/192.168.0.185:80/Plone/VirtualHostRoot/$1 [L,P]
ExpiresActive On
ExpiresByType image/gif A3600
ExpiresByType image/png A3600
ExpiresByType image/image/vnd.microsoft.icon A3600
ExpiresByType image/jpeg A3600
ExpiresByType text/css A3600
ExpiresByType text/javascript A3600
ExpiresByType application/x-javascript A3600
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
</IfModule>
</virtualHost>

在 /etc/apache2/site-available下增加文件zmi.gene.org.conf,这个用于ZMI管理,如添加站点等

(gene) plone@ubuntu1804:~$ cd /etc/apache2/site-available/
(gene) plone@ubuntu1804:/etc/apache2/site-available$ sudo touch zmi.gene.org.conf
(gene) plone@ubuntu1804:/etc/apache2/site-available$ sudo vi zmi.gene.org.conf

输入如下内容:


<VirtualHost *:80>
<Proxy *>
Allow from zmi.gene.org
</Proxy>
ServerName zmi.gene.org
ProxyPass / http://localhost:8883/
ProxyPassReverse / http://localhost:8883/
ProxyPreserveHost On
</VirtualHost>

在 /etc/apache2/site-enable下增加 符号连接:zmi.gene.org.conf

(gene) plone@ubuntu1804:/etc/apache2/site-available$ sudo ln -s /etc/apache2/site-available/zmi.gene.org.conf  /etc/apache2/site-enable/zmi.gene.org.conf

编辑apache配置文件:

sudo vi /etc/apache2/apache2.conf

调整Timeout参数:

#
PidFile ${APACHE_PID_FILE}

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 600
#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

-- INSERT --

重启apache:

(gene) plone@ubuntu1804:/etc/apache2/site-available$ sudo systemctl restart apache2.service

 

三、创建report目录并安装字体

创建report默认保存目录,并设置权限:

(gene) plone@ubuntu1804:/etc/apache2/site-available$ cd
(gene) plone@ubuntu1804:~$ sudo mkdir -p /srv/report_files

(gene) plone@ubuntu1804:~$ sudo chown -R plone:plone  /srv/report_files

安装字体:

(gene) plone@ubuntu1804:~$ cd workspace/downloads
(gene) plone@ubuntu1804:~/workspace/downloads$ unzip fonts.zip
(gene) plone@ubuntu1804:~/workspace/downloads$ sudo mv  fonts/truetype  /usr/share/fonts/
(gene) plone@ubuntu1804:~/workspace/downloads$ sudo mv  fonts/opentype  /usr/share/fonts/

 

四、检查libreoffice 安装是否成功

运行python3

(gene) plone@ubuntu1804:~$ cd workspace/gene
(gene) plone@ubuntu1804:~/workspace/gene$ deactive
plone@ubuntu1804:~/workspace/gene$ /usr/bin/python3

尝试导入uno 和 unohelper,应不报错,如下:

Python 3.6.8 (default, Apr  2 2020, 13:34:55) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import uno
>>> import unohelper
>>>

 

五、添加并配置Plone站点,完成gene项目初始化

  1. 添加站点:打开浏览器,访问http://zmi.gene.org/,输入管理员账户admin及密码,按照提示添加站点,站点id默认为Plone。
  2. 安装策略包,完成gene项目初始化

打开浏览器访问http://demo.gene.org/输入管理员账户admin及密码,登录后,点击左下角菜单中的“网站设置”。

在 “常规”组里面点击“附加组件”,在“可启用附加组件”中寻找gene.policy,找到后,点击其后的 “安装”按钮即可。

 

六、设置相关服务自启动

添加systemd管理的自启动服务

1、自启动supervisord

sudo touch /etc/systemd/system/supervisord.service
sudo vi /etc/systemd/system/supervisord.service

填充如下内容:

[Unit]
Description=Supervisor Monitor
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target

[Service]
User=root
Group=root
PIDFile=/home/plone/workspace/gene/var/supervisord.pid
# Disable service start and stop timeout logic of systemd for supervisor service.
TimeoutSec=0
Type=forking
# Start main service
ExecStart=/home/plone/workspace/gene/bin/supervisord
ExecStop=/home/plone/workspace/gene/bin/supervisorctl shutdown
StartLimitBurst=2
StartLimitInterval=30

允许supervisord 作为deamon自动启动:

sudo systemctl enable supervisord.service

2、自启动libreoffice 

sudo touch /etc/systemd/system/libreoffice.service
sudo vi /etc/systemd/system/libreoffice.service

填充如下内容:

 [Unit]
 Description=Control headless soffice instance
 After=network.target
 
 [Service]
 Type=simple
 ExecStart=/usr/bin/soffice --invisible --headless \
 '--accept=socket,host=127.0.0.1,port=2002;urp; '
 --pidfile=/var/run/soffice.pid
 RestartSec=5 
 PIDFile=/var/run/soffice.pid

 [Install]
 WantedBy=multi-user.target

允许libreoffice 作为deamon自动启动:

sudo systemctl enable libreoffice.service

补充:,需要注意的是,Python 2已于2020年1月1日停止维护,因此Ubuntu 20.04默认情况下可能不再提供Python 2的开发包。如果你确实需要Python 2的开发环境,可以考虑以下步骤:

  1. 添加旧版本的PPA(个人包档案): 你可以添加一个包含Python 2的PPA,例如deadsnakes PPA:

    sudo add-apt-repository ppa:deadsnakes/ppa
    sudo apt update
设置