Weblate 2.11安装配置文档

一、系统环境:

OS:CentOS 6.8 x64 Minimal
HostName:Weblate
IP:192.168.75.153
Python:2.7.13
pip:9.0.1
Weblate:2.11
Nginx:1.10.1
MySQL:5.5.54
Uwsgi:2.0.14
SELinux:关闭
Iptables:关闭

 

二、系统设置:

修改机器名:

[root@Weblate /]# vim /etc/sysconfig/network

  修改如下项目:

  HOSTNAME=Weblate

关闭SELinux

[root@Weblate /]# vim /etc/selinux/config

  SELINUX=disabled

关闭防火墙:

[root@Weblate /]# service iptables stop
[root@Weblate /]# chkconfig iptables off

重启系统使以上项目生效:

[root@Weblate /]# reboot

 

三、安装系统支撑软件包:

安装EPEL源:

[root@Weblate /]# yum -y install epel-release
[root@Weblate /]# yum clean all
[root@Weblate /]# yum makecache

安装常用软件:

[root@Weblate /]# yum -y install vim wegt git xz curl telnet

安装基础软件包:

[root@Weblate /]# yum -y install gcc gcc-c++ autoconf automake

安装Nginx所需的软件包:

[root@Weblate /]# yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel

安装Python所需的软件包:

[root@Weblate /]# yum -y install sqlite sqlite-devel bzip2 bzip2-devel readline readline-devel ncurses ncurses-devel gdbm gdbm-devel tk tk-devel tcl tcl-devel

安装Weblate所需的软件包:

[root@Weblate /]# yum -y install libjpeg libjpeg-devel freetype freetype-devel lcms lcms-devel libwebp libwebp-devel

 

四、安装Python

[root@Weblate /]# wget -P/usr/local/src/ -c https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tar.xz
[root@Weblate src]# tar -xJvf /usr/local/src/Python-2.7.13.tar.xz -C /usr/local/src/
[root@Weblate /]# cd /usr/local/src/Python-2.7.13
[root@Weblate Python-2.7.13]# ./configure --prefix=/usr/local/python
[root@Weblate Python-2.7.13]# make -j 4
[root@Weblate Python-2.7.13]# make install

添加Python命令到环境变量:

[root@Python /]# vim ~/.bash_profile

PATH=$PATH:$HOME/bin
改为:
PATH=$PATH:$HOME/bin:/usr/local/python/bin

 使环境变量生效:

[root@Python /]# source ~/.bash_profile

查看Python版本:

[root@Weblate /]# python2.7 -V
Python 2.7.13

更改系统默认Python版本为Python2.7

[root@Weblate /]# mv /usr/bin/python /usr/bin/python2.6
[root@Weblate /]# ln -s /usr/local/python/bin/python2.7 /usr/bin/python
[root@Weblate /]# python -V
Python 2.7.13

解决python升级后,YUM不能正常工作的问题:

[root@Weblate /]# vi /usr/bin/yum
将文件头部的
#!/usr/bin/python
改成
#!/usr/bin/python2.6

安装PIP:

[root@Weblate /]# wget -P/usr/local/src/ -c https://bootstrap.pypa.io/get-pip.py
[root@Weblate /]# python2.7 /usr/local/src/get-pip.py

查看pip版本:

[root@Weblate /]# pip2.7 -V
pip 9.0.1 from /usr/local/python/lib/python2.7/site-packages (python 2.7)

 

五、安装memcache

(weblate) [root@Weblate /]# yum -y install memcached
(weblate) [root@Weblate /]# service memcached start
(weblate) [root@Weblate /]# chkconfig memcached on
(weblate) [root@Weblate /]# pip2.7 install python-memcached

六、安装MySQL

(weblate) [root@Weblate /]# wget -P/usr/local/src/ -c https://downloads.mysql.com/archives/get/file/MySQL-5.5.53-1.el6.x86_64.rpm-bundle.tar
(weblate) [root@Weblate /]# tar -xvf MySQL-5.5.54-1.el6.x86_64.rpm-bundle.tar -C /usr/local/src/

删除系统自带mysql组件:

(weblate) [root@Weblate /]# rpm -e --nodeps mysql-libs-5.1.73-7.el6.x86_64

安装新版mysql组件:

(weblate) [root@Weblate /]# yum -y install /usr/local/src/MySQL-server-5.5.54-1.el6.x86_64.rpm
(weblate) [root@Weblate /]# yum -y install /usr/local/src/MySQL-devel-5.5.54-1.el6.x86_64.rpm
(weblate) [root@Weblate /]# yum -y install /usr/local/src/MySQL-shared-5.5.54-1.el6.x86_64.rpm
(weblate) [root@Weblate /]# yum -y install /usr/local/src/MySQL-client-5.5.54-1.el6.x86_64.rpm
(weblate) [root@Weblate /]# service mysql start
(weblate) [root@Weblate /]# chkconfig mysql on
(weblate) [root@Weblate /]# pip2.7 install MySQL-python

  注:MySQL-shared这个包一定要装,不然安装MySQL-python会报错,切记!

设置mysql管理员密码:

(weblate) [root@Weblate /]# mysqladmin -u root password 'hui123'

创建weblate数据库:

(weblate) [root@Weblate /]# mysql -uroot -phui123
mysql> CREATE DATABASE weblate CHAR SET UTF8;

 

七、安装Weblate

[root@Weblate /]# wget -P/usr/local/src/ -c https://dl.cihar.com/weblate/Weblate-2.11.tar.gz
[root@Weblate src]# tar -xzvf /usr/local/src/Weblate-2.11.tar.gz -C /usr/local/src/
[root@Weblate /]# mv /usr/local/src/Weblate-2.11 /usr/local/weblate

安装虚拟环境插件:

[root@Weblate /]# pip2.7 install virtualenv

创建虚拟环境并激活:

[root@Weblate /]# virtualenv --python=/usr/local/python/bin/python2.7 /usr/local/weblate
[root@Weblate /]# source /usr/local/weblate/bin/activate

安装运行weblate 所需的Python组件:

(weblate) [root@Weblate weblate]# cd /usr/local/weblate
(weblate) [root@Weblate weblate]# pip2.7 install -r requirements.txt -i https://pypi.doubanio.com/simple/
(weblate) [root@Weblate weblate]# pip2.7 install -r requirements-optional.txt -i https://pypi.doubanio.com/simple/

  注:https://pypi.doubanio.com/simple/为豆瓣的源,速度比官方的快的不是一点半点!

创建Weblate数据库连接配置文件:

(weblate) [root@Weblate /]# cp /usr/local/weblate/weblate/settings_example.py /usr/local/weblate/weblate/settings.py
(weblate) [root@Weblate /]# vim /usr/local/weblate/weblate/settings.py
按照如下内容修改内容
DATABASES = {
    'default': {
        # Use 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'ENGINE': 'django.db.backends.mysql',
        # Database name or path to database file if using sqlite3.
        'NAME': 'weblate',
        # Database user, not used with sqlite3.
        'USER': 'root',
        # Database password, not used with sqlite3.
        'PASSWORD': 'hui123',
        # Set to empty string for localhost. Not used with sqlite3.
        'HOST': '127.0.0.1',
        # Set to empty string for default. Not used with sqlite3.
        'PORT': '',
    }
}

初始化数据库:

(weblate) [root@Weblate /]# python2.7 /usr/local/weblate/manage.py migrate

创建Weblate管理员账号:

(weblate) [root@Weblate /]# python2.7 /usr/local/weblate/manage.py createadmin
Creating user admin with password 3@mSnRUNYljns

  注:这里生成的密码就是用来登录Weblate系统的。

测试服务是否正常启动:

(weblate) [root@Weblate /]# python2.7 /usr/local/weblate/manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
March 01, 2017 - 08:51:12
Django version 1.10.5, using settings 'weblate.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[root@Weblate ~]# curl http://127.0.0.1:8000/

 

八、安装uWSGI

(weblate) [root@Weblate /]# pip2.7 install uwsgi
(weblate) [root@Weblate /]# uwsgi --version
2.0.14

创建uWSGI配置文件:

(weblate) [root@Weblate /]# vim /etc/uwsgi9090.ini

配置文件内容如下:
[uwsgi]
# plugins       = python
master        = true
protocol      = uwsgi
socket        = 127.0.0.1:9090
wsgi-file     = /usr/local/weblate/weblate/wsgi.py
python-path   = /usr/local/weblate
# Needed for OAuth/OpenID
buffer-size   = 8192
# Increase number of workers for heavily loaded sites
# workers       = 6
# Needed for background processing
enable-threads = true
chdir = /usr/local/weblate
home = /usr/local/weblate
vhost = true
pidfile = /var/run/uwsgi9090.pid
daemonize = /var/log/uwsgi9090.log

 

九、安装Nginx:

(weblate) [root@Weblate src]# wget -P/usr/local/src/ -c http://nginx.org/download/nginx-1.10.3.tar.gz
(weblate) [root@Weblate src]# tar -xzvf /usr/local/src/nginx-1.10.1.tar.gz -C /usr/local/src/
(weblate) [root@Weblate src]# cd /usr/local/src/nginx-1.10.1
(weblate) [root@Weblate nginx-1.10.1]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module
(weblate) [root@Weblate nginx-1.10.1]# make -j 2
(weblate) [root@Weblate nginx-1.10.1]# make install

配置Nginx

(weblate) [root@Weblate /]# vim /usr/local/nginx/conf/nginx.conf

将如下代码替换对应的代码:

    server {

        listen 80;
        server_name weblate;
        root /usr/local/weblate; 

        location /favicon.ico {
                alias /usr/local/weblate/weblate/static/favicon.ico;
                expires 30d;
        } 

        location /static/ {
                alias /usr/local/weblate/weblate/static/;
                expires 30d;
        } 

        location /robots.txt {
                alias /usr/loca/weblate/weblate/static/robots.txt;
                expires 30d;
        } 

        location /static/admin/ {
                alias /usr/local/weblate/lib/python2.7/site-packages/django/contrib/admin/static/admin/;
                expires 30d;
        } 

        location / {
                include uwsgi_params;
                # Needed for long running operations in admin interface
                uwsgi_read_timeout 3600;
                uwsgi_pass 127.0.0.1:9090;
        }

}

检查Nginx的配置文件:

(weblate) [root@Weblate /]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

 

十、增加开机启动项:

(weblate) [root@Weblate /]# vim /etc/rc.local

添加如下内容

source /usr/local/weblate/bin/activate
pkill -9 uwsgi
uwsgi /etc/uwsgi9090.ini
pkill -9 nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

 

十一、排错:

在浏览器访问,会出现以下错误:

  

[root@Weblate /]# vim /usr/local/weblate/lib/python2.7/site-packages/django/http/request.py

  修改如下项目,添加服务器的IP或者域名信息:

# Allow variants of localhost if ALLOWED_HOSTS is empty and DEBUG=True.
allowed_hosts = settings.ALLOWED_HOSTS
if settings.DEBUG and not allowed_hosts:
    allowed_hosts = ['localhost', '127.0.0.1', '192.168.75.153', '[::1]']

 

附件1Python各插件版本信息:

(weblate) [root@Weblate /]# pip2.7 list --format=columns

Package                Version
---------------------- --------
appdirs                     1.4.2 
Babel                     2.3.4  
chardet                    2.3.0  
defusedxml                  0.5.0  
diff-match-patch               20121119
Django                     1.10.5 
django-appconf               1.0.2  
django-compressor            2.1.1  
django-crispy-forms             1.6.1  
djangorestframework          3.5.4  
lxml                       3.7.3  
mercurial                   4.1    
MySQL-python              1.2.5  
oauthlib                     2.0.1  
olefile                       0.44   
packaging                  16.8   
Pillow                      4.0.0  
pip                        9.0.1  
pydns                     2.3.6  
PyJWT                  1.4.2  
pyLibravatar              1.7    
pyparsing                   2.1.10 
python-bidi                   0.4.0  
python-dateutil                2.6.0  
python-memcached       1.58   
python-openid              2.2.5  
pytz                       2016.10
pyuca                  1.1.2  
PyYAML                 3.12   
rcssmin                 1.0.6  
requests               2.13.0 
requests-oauthlib        0.8.0  
rjsmin                 1.0.12 
setuptools              34.3.0 
six                    1.10.0 
social-auth-app-django    1.1.0  
social-auth-core         1.2.0  
translate-toolkit         2.0.0  
uWSGI                2.0.14 
wheel                0.29.0 
Whoosh              2.7.4  

 

附件2:Python各模块功能说明:

Python编译过程中会提示缺少模块,下表为各模块功能说明:

Python build finished, but the necessary bits to build these modules were not found:

_bsddb             _curses            _curses_panel  
_sqlite3           _tkinter           bsddb185       
bz2                dbm                dl             
gdbm               imageop            readline       
sunaudiodev                                          

To find the necessary bits, look in setup.py in detect_modules() for the module's name.

 

模块

依赖

说明

_bsddb

bsddb

Interface to Berkeley DB library。Berkeley数据库的接口

_curses

ncurses-devel

Terminal handling for character-cell displays。

_curses_panel

ncurses-devel

A panel stack extension for curses。

_sqlite3

sqlite-devel

DB-API 2.0 interface for SQLite databases。SqlLite,CentOS可以安装sqlite-devel

_ssl

openssl-devel

TLS/SSL wrapper for socket objects。

_tkinter

tk-devel tcl-devel

a thin object-oriented layer on top of Tcl/Tk。如果不使用桌面程序可以忽略TKinter

bsddb185

old bsddb module

老的bsddb模块,可忽略。

bz2

bzip2-devel

Compression compatible with bzip2。bzip2-devel

dbm

 gdbm-devel

Simple “database” interface。

dl

N/A

Call C functions in shared objects.Python2.6开始,已经弃用。

gdbm

 gdbm-devel

GNU’s reinterpretation of dbm

imageop

N/A

Manipulate raw image data。已经弃用。

readline

readline-devel

GNU readline interface

sunaudiodev

N/A

Access to Sun audio hardware。这个是针对Sun平台的,CentOS下可以忽略

zlib

Zlib-devel

Compression compatible with gzip

 

[THE END]

原文地址:https://www.cnblogs.com/configure/p/6485728.html