目标:安装ReviewBoard2.5.13
环境: 阿里云centos6.8新系统
注意:如果已安装某些软件包,可能造成安装失败,请根据情况卸载后重新安装
安装python2.7及reviewboard
执行以下步骤安装python2.7及reviewboard,可拷贝成脚本执行,假设脚本名为install_reviewboard.sh,执行sudo ./install_reviewboard.sh,注意脚本要有可执行权限。
# 安装及配置python2.7
yum install -y https://centos6.iuscommunity.org/ius-release.rpm
yum install -y python27 python27-devel python27-libs python27-pip python27-setuptools mysql-devel
[ ! -e /usr/bin/python2.6.6 ] && (
mv /usr/bin/python /usr/bin/python2.6.6
ln -s /usr/bin/python2.7 /usr/bin/python
)
grep -q "python2.6.6" /usr/bin/yum || sed -i '1s/python/python2.6.6/g' /usr/bin/yum
[ ! -e /usr/bin/pip2.6 ] && (
mv /usr/bin/pip /usr/bin/pip2.6
ln -s /usr/bin/pip2.7 /usr/bin/pip
)
[ ! -e /usr/bin/easy_install-2.6 ] && (
mv /usr/bin/easy_install /usr/bin/easy_install-2.6
ln -s /usr/bin/easy_install-2.7 /usr/bin/easy_install
)
# 安装依赖包
yum remove -y httpd-tools httpd
yum install -y httpd24u httpd24u-tools httpd24u-devel gcc libffi-devel openssl-devel patch memcached mysql-server
pip install python-memcached
# 安装ReviewBoard
pip install ReviewBoard
# 安装数据库绑定
pip install -U mysql-python
# 启动服务
service memcached restart
# 可以设置服务成开机启动
chkconfig mysqld --level 35 on
chkconfig httpd --level 35 on
chkconfig memcached --level 35 on
配置mysql
sudo vim /etc/my.cnf
# 加入如下配置
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
# 启动并创建数据库,事后需要重设密码等
sudo service mysqld restart
mysql -u root -p
mysql> CREATE DATABASE reviewboard CHARACTER SET utf8;
mysql> CREATE USER 'reviewboard'@'localhost' IDENTIFIED BY 'reviewboard';
mysql> GRANT ALL PRIVILEGES ON reviewboard.* to 'reviewboard'@'localhost';
mysql> quit
创建站点
需要确定reviewboard站点存储位置,例如为/var/www/reviewboard,注意这个目录当前不应当存在
sudo rb-site install /var/www/reviewboard
根据提示进行设置,以下假设跟着默认的来:
Domain Name: 192.168.1.111(假设本机ip作为web站点,最好使用域名)
Root Path [/]: (回车)
Database Type: 1
Database Name [reviewboard]: (reviewboard的数据库名,回车)
Database Server [localhost]: (回车)
Database Username: reviewboard(数据库用户名)
Database Password: reviewboard(数据库用户密码)
Confirm Database Password:reviewboard
Memcache Server [localhost:11211/]: (回车)
Username [admin]: admin(管理员名称)
Password: *(管理员登陆密码)
Confirm Password [*]:
E-Mail Address: yours@email.com.cn(邮箱地址)
Company/Organization Name (optional):(公司名,可选填,回车即可)
Allow us to collect support data? [Y/n]: n
配置站点
sudo chown -R apache:apache /var/www/reviewboard/htdocs/media/uploaded
sudo chown -R apache:apache /var/www/reviewboard/data
sudo chown -R apache:apache /var/www/reviewboard/htdocs/media/ext
sudo chown -R apache:apache /var/www/reviewboard/htdocs/static/ext
sudo cp /var/www/reviewboard/conf/apache-wsgi.conf /etc/httpd/conf.d/reviewboard.conf
# 需要编译并配置mod_wsgi,这里使用4.5.12版本,可以尝试其他版本
sudo yum remove -y mod_wsgi
wget https://github.com/GrahamDumpleton/mod_wsgi/archive/4.5.12.tar.gz
tar zxvf 4.5.12.tar.gz
cd mod_wsgi-4.5.12
./configure
make
sudo make install
# 配置一下apache
cd /etc/httpd/conf.modules.d
sudo vim 02-wsgi.conf
# 添加如下内容
LoadModule wsgi_module modules/mod_wsgi.so
# 重启服务
sudo service httpd restart
其他设置
# 假如有selinux和iptables
sudo setenforce 0
sudo /sbin/iptables -I INPUT -p tcp –dport 80-j ACCEPT
可以访问站点试试了
使用Gitlab注意点
Reviewboard2.5.13无法使用gitlab的hosting service,解决办法
sudo vim /usr/lib/python2.7/site-packages/reviewboard/hostingsvcs/service.py
# 在函数build_form_data中content_parts.append下面添加:
content_parts.append(
b'--%(boundary)s--\r\n'
% {
'boundary': boundary,
}
)
# 注意与上面的for对齐
重启下httpd再试试
sudo service httpd restart