reviewboard安装好后,需要在apache上配置站点才能访问,包括域名,安装根目录等等
官方文档地址:https://www.reviewboard.org/docs/manual/1.7/admin/installation/creating-sites/#creating-sites
创建reviewboard站点
sudo rb-site install /var/www/reviewboard
之后会有一些配置向导
· Domain = localhost
· Root Path = /
· Media URL = media/
· Database Type = mysql
· Database Name = reviewboard
· Database server = localhost
· Database username = 'reviewboard'
· Database password = 'reviewboard'
· Cache Type = memcache
· Memcache Server = memcached://localhost:11211/
· Webserver = apache
· Python loader = modpython 一般按照默认的配置就可以了
启动apache
sudo chown apache /var/www/reviewboard/*
cp /var/www/reviewboard/conf/apache-wsgi.conf /etc/httpd/conf.d/
service httpd restart 使用域名加端口号(默认端口80)就能访问了。域名没配好的话,直接使用地址访问:http://XXXX:80/ 打开之后就可以看见登录的界面了: ![reviewboard登录界面](/assets/images/2014/reviewboard-login.png)
不过有几个地方需要注意,如果访问的时候报500错误,可以在/etc/httpd/conf/httpd.conf根目录加上这样的配置:
<Directory />
Options FollowSymLinks
AllowOverride None
Satisfy Any
</Directory>
Satisfy Any后就没有500错误
如果有报400的错误,说明是访问url有问题,需要更改一个地方
vim /var/www/reviewboard/conf/settings_local.py
修改文件中ALLOWED_HOSTS = [‘*’]
注意问题
使用python操作svn
使用reviewboard创建repository时,需要使用相应的支持svn的python库模块,有两种模块可供选择,一种是pysvn(推荐)一种是subvertpy。但是如果两种都安装了的话,reviewboard会默认选择subvertpy。有一种方法可以避免这种情况,可以更改setting_local.py中SVNTOOLS_BACKENDS的配置:
SVNTOOL_BACKENDS = [
'reviewboard.scmtools.svn.pysvn',
'reviewboard.scmtools.svn.subvertpy',
]
建议即使只安装了pysvn模块的也更改此处,避免出问题。
reviewboard发送邮件
首先使用admin登录reviewboard系统,进入admin设置页面,点击右侧的Emails,然后进行配置,主要注意几个地方:
-
Sender e-mail address
发送邮件的地址,将其设置为e-mail header中的Sender字段。e-mail header中的From字段设置成发起评审的人的邮件地址。
-
Mail Server
发送邮件的SMTP服务器地址。注:需要将发送邮件地址的smtp服务打开
-
Port
SMTP服务端口号,默认是25
邮件配置完成后,发现发送不了邮件,查看apache error log,发现报如下错误:
[Thu Nov 20 08:12:50 2014] [error] Traceback (most recent call last):
[Thu Nov 20 08:12:50 2014] [error] File "/usr/local/lib/python2.7/site-packages/ReviewBoard-2.0.11-py2.7.egg/reviewboard/notifications/email.py", l
ine 286, in send_review_mail
[Thu Nov 20 08:12:50 2014] [error] message.send()
[Thu Nov 20 08:12:50 2014] [error] File "/usr/local/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/core/mail/message.py", line 276, in send
[Thu Nov 20 08:12:50 2014] [error] return self.get_connection(fail_silently).send_messages([self])
[Thu Nov 20 08:12:50 2014] [error] File "/usr/local/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/core/mail/backends/smtp.py", line 94,in send_messages
[Thu Nov 20 08:12:50 2014] [error] sent = self._send(message)
[Thu Nov 20 08:12:50 2014] [error] File "/usr/local/lib/python2.7/site-packages/Django-1.6.8-py2.7.egg/django/core/mail/backends/smtp.py", line 110, in _send
[Thu Nov 20 08:12:50 2014] [error] self.connection.sendmail(from_email, recipients, message.as_bytes())
[Thu Nov 20 08:12:50 2014] [error] File "/usr/local/lib/python2.7/smtplib.py", line 737, in sendmail
[Thu Nov 20 08:12:50 2014] [error] raise SMTPDataError(code, resp)
[Thu Nov 20 08:12:50 2014] [error] SMTPDataError: (553, 'Envolope sender mismatch with header from.')
从最后抛出的异常来看,应该是sender字段和from字段不匹配,造成使用smtplib调用sendmail函数时,抛出异常。我不知道会不会是reviewboard的bug,或者是我配置不正确,但要解决这个问题还是比较容易的,根据调用栈,找出reviewboard的源码文件email.py,找出init函数,将From字段设置成Sender字段值即可:
def __init__(self, subject, text_body, html_body, from_email, sender,
to, cc, in_reply_to, headers={}):
headers = headers.copy()
siteconfig = SiteConfiguration.objects.get_current()
if sender:
headers['Sender'] = sender
headers['X-Sender'] = sender
if in_reply_to:
headers['In-Reply-To'] = in_reply_to
headers['References'] = in_reply_to
headers['Reply-To'] = from_email
# If enabled (through 'mail_enable_autogenerated_header' site
# configuration), mark the mail as 'auto-generated' (according to
# RFC 3834) to hopefully avoid auto replies.
if siteconfig.get("mail_enable_autogenerated_header"):
headers['Auto-Submitted'] = 'auto-generated'
#headers['From'] = from_email
#设置成sender
headers['From'] = sender
super(SpiffyEmailMessage, self).__init__(subject, text_body,
settings.DEFAULT_FROM_EMAIL,
to, headers=headers)
self.cc = cc or []
self.message_id = None
self.attach_alternative(html_body, "text/html")