在CentOS6.10安装Reviewboard
安装步骤官网有详细介绍,这里分享个人安装过程总采用两种方式:EPEL源安装和普通安装(CentOS我是选择最小化安装)。
EPEL安装
- 安装源
# yum -y install wget
# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo # 这里需要手动更新里面参数centos6对应64位
# mv /etc/yum.repo.d/CentOS-* /etc/yum.repo.d/backup
# yum repolist # 检查yum源配置是否包含epel和163源
# yum clean all # 更新缓存
# yum makecache
# yum groupinstall "base" # 安装基础依赖,方便后续使用
- 安装MySQL(因为Reviewboard1.7.x推荐mysql5.0.+,所以没添加新源安装5.5以上版本了)
# yum install mysql-devel mysql-server
# vim /etc/my.cnf
--------------------------------------------
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
--------------------------------------------
# service mysqld start
# /usr/bin/mysql_secure_installation # 进行安全设置,这里按照提示操作即可,简单
# mysql -u root -p
# mysql> CREATE DATABASE reviewboard CHARACTER SET utf8 COLLATE utf8_general_ci;
# mysql> CREATE USER 'reviewboarder' IDENTIFIED BY 'reviewboarder';
# mysql> GRANT ALL ON reviewboard.* TO 'reviewboarder'@'%' IDENTIFIED BY 'reviewboarder';
# mysql> GRANT ALL ON reviewboard.* TO 'reviewboarder'@'localhost' IDENTIFIED BY 'reviewboarder';
- 安装Memcached
# yum install memcached
- 安装ReviewBoard
# yum install python-devel python-simplejson # 安装缺少的依赖
# wget http://springdale.math.ias.edu/data/puias/unsupported/6/x86_64/Django14-1.4.14-1.sdl6.noarch.rpm
# rpm -ivh Django14-1.4.14-1.sdl6.noarch.rpm # 安装缺少的依赖
# yum install ReviewBoard # 通过EPEL源安装RB
- 创建Review Board Site
# service mysqld start
# service memcached start
# service httpd start
# rb-site install /opt/reviewboard/reviewboard_1.7.27/www #安装在这个目录,无论我怎么赋予权限,reviewboard总提示我需要给下面的指定目录chown -R apache,最后放/var/www/reviewboard就对了,还没时间去查原因,估计是我对apache不熟
安装成功提示如下:
OK
Setting up support ... OK
* The site has been installed
The site has been installed in
/opt/reviewboard/reviewboard_1.7.27/www
Sample configuration files for web servers and cron are available
in the conf/ directory.
You need to modify the ownership of the following directories and
their contents to be owned by the web server:
*
/opt/reviewboard/reviewboard_1.7.27/www/htdocs/media/uploaded
* /opt/reviewboard/reviewboard_1.7.27/www/htdocs/media/ext
* /opt/reviewboard/reviewboard_1.7.27/www/data
For more information, visit:
https://www.reviewboard.org/docs/manual/dev/admin/installation/creating-sites/
* Get more out of Review Board
To enable PDF document review, enhanced scalability, GitHub
Enterprise support, and more, download Power Pack at:
https://www.reviewboard.org/powerpack/
Your install key for Power Pack is:
56a4d676578a7549d4700ac57e0580d070d2b2bb
Support contracts for Review Board are also available:
https://www.beanbaginc.com/support/contracts/
- 进行apache配置,然后确保mysql和memcached启动,重启httpd,即可访问reviewboard
# cp www/conf/apache-wsgi.conf /etc/httpd/conf.d/
- 安全设置
- 配置SELinux,让web服务进程可以发送邮件,访问缓存服务,连接远程数据库并支持上传代码对照差异。
# setsebool -P httpd_can_sendmail 1
# setsebool -P httpd_can_network_memcache 1
# setsebool -P httpd_can_network_connect_db 1
# setsebool -P httpd_unified 1
- 防火墙打开80端口,这里略过
结果
配置遇到2个问题,memcached(配置不报错,但提示无法从缓存读写数据,这个应该是SELinux未配置)和subversion连接不上(日志提示连接svn服务do not have permission,估计是pysvn兼容问题,我在下一种操作遇到另外一种错,要求安装subvertpy,最后手动安装pysvn1.8,问题解决)
常规安装
第一种安装最终没能成功,无奈只好通过官网手动安装,鉴于安装这个遇到问题较多,建议用虚拟机+快照方式安装,这样可以放手弄,一旦走入死胡同,立即还原重来。
- 安装源
# cd /etc/yum.repo.d
# mv /etc/yum.repo.d/CentOS-* /etc/yum.repo.d/backup
# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo # 这里需要手动更新里面参数centos6对应64位
# yum repolist # 检查yum源配置是否包含epel和163源
# yum clean all # 更新缓存
# yum makecache
# yum groupinstall "base" # 安装基础依赖,方便后续使用
- 执行安装脚本
上传安装reviewboard脚本,注意设定打算安装的ReviewBoard版本,脚本来源作者zzzyyyttt分享
#!/bin/bash
# 安装及配置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
# 补充下面一行,即便没有该行测试安装完全ok的
pip install --upgrade pip
pip install python-memcached
# 安装ReviewBoard,补充定义安装版本,否则取最新版本安装
pip install ReviewBoard==2.5.17
# 安装数据库绑定
pip install -U mysql-python
# 启动服务
service memcached restart
# 可以设置服务成开机启动
chkconfig mysqld --level 35 on
chkconfig httpd --level 35 on
chkconfig memcached --level 35 on
对脚本进行准备执行
# yum -y install dos2unix
# dos2unix reviewboard_install.sh
# chmod +x reviewboard_install.sh
执行脚本,安装reviewboard
# ./reviewboard_install.sh
- 安装mysql5.6(略)和subversion1.8.19(取决于安装reviewboard版本)
# yum remove subversion*
# vi /etc/yum.repos.d/wandisco-svn.repo
-------------------------------------------------------------------
[WandiscoSVN]
name=Wandisco SVN Repo
baseurl=http://opensource.wandisco.com/centos/6/svn-1.8/RPMS/x86_64/
enabled=1
gpgcheck=0
-------------------------------------------------------------------
# yum install subversion
本人安装遇到svn无法连接,即便centos安装了pysvn,所以只能手动下载安装包安装,我也试过subvertpy,安装更简单而且也能用,但官网强烈推荐pysvn,兼容更好。
- 安装必要依赖
# yum -y install apr-devel apr-util-devel gcc-c++ subversion-devel
手动安装依赖:pycxx
# wget https://ayera.dl.sourceforge.net/project/cxx/CXX/PyCXX%20V6.2.8/pycxx-6.2.8.tar.gz
# tar -zxf pycxx-6.2.8.tar.gz
# cd pycxx-6.2.8
# python setup.py install
- 下载安装pysvn
注意,我先下载的1.9.7版本,结果编译时,一堆语法错误,1.8就顺利通过。
# 下载构建
# wget http://tigris.org/files/documents/1233/49465/pysvn-1.8.0.tar.gz
# tar -zxf pysvn-1.8.0.tar.gz
# cd pysvn-1.8.0/Sources
# python setup.py configure
# make
# 若安装后保险起见,可以测试一下
# cd ../Tests
# make # 执行一堆测试,输出success就恭喜了
# 安装
# mkdir -p /usr/lib/python2.7/site-packages/pysvn # 这里注意检查自己系统中的python目录,find搜下
# cd pysvn-1.8.0/Sources
# cp pysvn/__init__.py /usr/lib/python2.7/site-packages/pysvn
# cp pysvn/_pysvn*.so /usr/lib/python2.7/site-packages/pysvn
- Create Site
执行该步以前,至少确保mysql已经启动,否则安装无法初始化表和数据。
# rb-site install /var/www/reviewboard
注意:上面命令会让你填各种配置,1.7和2.5版本的问题差不多,但2.5版本要求输入组织机构时,不要填写中文,否则进入管理页面就会报500:
UnicodeEncodeError: ‘ascii’ codec can’t encode
安装成功后,按照提示给予目录权限,注意apache是httpd默认用户。
# chown -R apache:apache /var/www/reviewboard/htdocs/media/uploaded
# chown -R apache:apache /var/www/reviewboard/htdocs/media/ext
# chown -R apache:apache /var/www/reviewboard/htdocs/static/ext
# chown -R apache:apache /var/www/reviewboard/data
# vi /etc/httpd/conf/httpd.conf
--------------------------------------------
ServerName localhost:80
--------------------------------------------
vi /etc/hosts
--------------------------------------------
192.168.0.239 reviewboard-server # 服务器ip或者域名
--------------------------------------------
- Apache配置(这一步也是引用作者zzzyyyttt分享)
# cp /var/www/reviewboard/conf/apache-wsgi.conf /etc/httpd/conf.d/reviewboard.conf
# yum remove -y mod_wsgi
# wget https://github.com/GrahamDumpleton/mod_wsgi/archive/4.5.12.tar.gz
# tar -zxf 4.5.12.tar.gz
# cd mod_wsgi-4.5.12
# ./configure
# make
# make install
# cd /etc/httpd/conf.modules.d
# vim 02-wsgi.conf
--------------------------------------------
LoadModule wsgi_module modules/mod_wsgi.so
--------------------------------------------
# 重启服务
# service httpd restart
- 安全设置
- SELinux
# setsebool -P httpd_can_sendmail 1
# setsebool -P httpd_can_network_memcache 1
# setsebool -P httpd_can_network_connect_db 1
# setsebool -P httpd_unified 1
- 防火墙80端口(略)
总结
- 不急于安装,把官网安装手册通读再弄。因为没有读到官网最后提醒Redhat和Fedora需要配置SELinux,导致Memcached连不上,卡我半天。
- 不建议安装过高版本,除非功能需要。因为一般最新版本对其他依赖的版本要求也高,这样会导致你不得不升级安装很多东西,比如我安装的subversion1.8,那么下载安装pysvn1.8版本最合适,安装
最兼容
版本最好。 - 用虚拟机实践,多备份,提高效率。本人不是运维,一开始弄砸了,不得不重装操作系统,幸好是虚拟机,不然得跑机房弄。
- 如果需要上正式环境使用的,别偷懒,自己研究从头安装。一开始我拿bitnami的镜像来用,结果发现有一些自定义配置时候,因为不是自己安装的系统,很难维护,最后放弃使用。
后续补充
- 配置篇
- pre-commit拦截实现reviewboard和subversion集成
- 常见问题
网友评论