數據庫:使用review board默認支持的sqlit
版本管理倉庫:svn
1 安裝依賴包
sudo apt-get install apache2
sudo apt-get install libapache2-mod-python
sudo apt-get install libapache2-mod-wsgi
sudo apt-get install Memcached
sudo apt-get install memcached-dev
sudo apt-get install python-memcache
sudo apt-get install patch
sudo apt-get install subversion
sudo apt-get install python-svn
2 安裝review board
sudo pip install --upgrade setuptools
sudo pip install reviewboard
報錯:
Collecting PIL (from Djblets<0.8,>=0.7.32->reviewboard)
ERROR: Could not find a version that satisfies the requirement PIL (from Djblets<0.8,>=0.7.32->reviewboard) (from versions: none)
ERROR: No matching distribution found for PIL (from Djblets<0.8,>=0.7.32->reviewboard)
解決方法:
python -m pip install --upgrade pip
下載的是ReviewBoared1.7的配套依賴,因爲/usr/local/lib/python2.7/dist-packages下已經有ReviewBoard-1.7.29-py2.7.egg文件夾,將這個文件夾命名爲ReviewBoard-1.7.29-py2.7.egg_bk就可以了。
再次執行sudo -H pip install reviewboard
就會下載最新的ReviewBoard.
發現要下載的包太多了,會超時。於是,把pip超時設置爲3600秒。
sudo -H pip –timeout 3600 install reviewboard
安裝成功,打印下面的語句:
Successfully built django-oauth-toolkit django-multiselectfield mimeparse django-cors-headers pillowfight publicsuffix feedparser oauthlib PyYAML pycparser
Installing collected packages: pytz, markdown, pymdown-extensions, Pygments, Pillow, pillowfight, publicsuffix, futures, django-pipeline, python-dateutil, Django, dnspython, feedparser, Djblets, Whoosh, python-memcached, django-braces, oauthlib, django-oauth-toolkit, pycparser, cffi, pynacl, pyasn1, bcrypt, paramiko, django-evolution, urllib3, certifi, chardet, requests, requests-oauthlib, asana, PyYAML, rbintegrations, django-multiselectfield, mimeparse, django-cors-headers, docutils, django-haystack, reviewboard
Successfully installed Django-1.6.11 Djblets-1.0.11 Pillow-6.0.0 PyYAML-5.1 Pygments-2.4.2 Whoosh-2.7.4 asana-0.8.2 bcrypt-3.1.6 certifi-2019.3.9 cffi-1.12.3 chardet-3.0.4 django-braces-1.13.0 django-cors-headers-1.1.0 django-evolution-0.7.8 django-haystack-2.4.1 django-multiselectfield-0.1.8 django-oauth-toolkit-0.9.0 django-pipeline-1.6.14 dnspython-1.16.0 docutils-0.14 feedparser-5.2.1 futures-3.2.0 markdown-2.6.11 mimeparse-0.1.3 oauthlib-1.0.1 paramiko-2.4.2 pillowfight-0.3 publicsuffix-1.1.0 pyasn1-0.4.5 pycparser-2.19 pymdown-extensions-3.5 pynacl-1.3.0 python-dateutil-2.8.0 python-memcached-1.59 pytz-2019.1 rbintegrations-1.0 requests-2.22.0 requests-oauthlib-0.8.0 reviewboard-3.0.14 urllib3-1.25.3
到此,已安裝成功review board.
3 配置站點:
sudo rb-site install /var/www/html/reviewboard
在彈出的一系列配置項裏配置爲以下的值:
Domain = localhost
Root Path = / (默認)
Database Type = sqlite
Memcached Server = localhost:11211 (默認)
Username = zhangjing
Password = 密碼
Confirm Password = 密碼
E-mail = [email protected]
Company/Organization = 隨意
Allow us to collect support data = n
4 修改目錄權限
sudo chown -R www-data /var/www/html/reviewboard/htdocs/media/uploaded/
sudo chown -R www-data /var/www/html/reviewboard/htdocs/media/ext
sudo chown -R www-data /var/www/html/reviewboard/data
5 拷貝配置文件
sudo cd /etc/apache2/sites-available
sudo cp /var/www/html/reviewboard/conf/apache-wsgi.conf reviewboard.conf
sudo cd ../sites-enabled
sudo ln -s ../sites-available/reviewboard.conf .
sudo a2ensite reviewboard
由於apache2服務器配置了mantis,需要讓apache2配置2個網站
6 配置網站服務器
Cd /etc/apache2
修改ports.conf,增加Listen 8060:
Listen 8050
Listen 8060
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
修改/etc/apache2/sites-enabled/000-default.conf,
把reviewboard.conf的內容copy到000-default.conf中:
<VirtualHost *:8050>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/mantisbt
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
ServerName bt.example.com
ServerAlias www.bt.example.com
<Directory "/var/www/html/mantisbt/">
DirectoryIndex index.php index.html
Options FollowSymLinks
AllowOverride None
Require all granted
Options MultiViews FollowSymlinks
</Directory>
</VirtualHost>
<VirtualHost *:8060>
ServerName localhost
DocumentRoot "/var/www/html/reviewboard/htdocs"
# Error handlers
ErrorDocument 500 /errordocs/500.html
WSGIPassAuthorization On
WSGIScriptAlias "/" "/var/www/html/reviewboard/htdocs/reviewboard.wsgi/"
<Directory "/var/www/html/reviewboard/htdocs">
AllowOverride All
Options -Indexes +FollowSymLinks
Allow from all
</Directory>
# Prevent the server from processing or allowing the rendering of
# certain file types.
<Location "/media/uploaded">
SetHandler None
Options None
AddType text/plain .html .htm .shtml .php .php3 .php4 .php5 .phps .asp
AddType text/plain .pl .py .fcgi .cgi .phtml .phtm .pht .jsp .sh .rb
<IfModule mod_php5.c>
php_flag engine off
</IfModule>
# Force all uploaded media files to download.
<IfModule mod_headers.c>
Header set Content-Disposition "attachment"
</IfModule>
</Location>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# Alias static media requests to filesystem
Alias /media "/var/www/html/reviewboard/htdocs/media"
Alias /static "/var/www/html/reviewboard/htdocs/static"
Alias /errordocs "/var/www/html/reviewboard/htdocs/errordocs"
Alias /favicon.ico "/var/www/html/reviewboard/htdocs/static/rb/images/favicon.png"
</VirtualHost>
重啓apache2
sudo systemctl restart apache2
查看端口情況
sudo netstat -apn | grep apache2
查看apache2的網頁http://ip:8060,報錯:
[Wed May 29 17:11:47.363190 2019] [wsgi:crit] [pid 29085] mod_wsgi (pid=29085): The mod_python module can not be used in conjunction with mod_wsgi 4.0+. Remove the mod_python module from the Apache configuration.
AH00016: Configuration Failed
卸載mod-python
sudo apt-get remove --purge libapache2-mod-python
發現卸載的是3.3.3版本的mod_python,推斷應該是mod_python 3.3.3不是最新版本。
再次訪問http://ip:8060網頁,報錯:
[Wed May 29 10:38:56.424436 2019] [wsgi:error] [pid 4199] [client 192.168.2.40:56319] No handlers could be found for logger "djblets.extensions.manager"
還是需要安裝mod_python組件。
https://github.com/grisha/mod_python
clone git上的最新代碼,就是mod_python3.5.0版本的。
$ ./configure
$ make
$ sudo make install
裝的過程中報錯:rely on aspx
Aspx是apache2-dev的一個組件
sudo apt install apache2-dev
都安裝好後,訪問http://192.168.2.249:8060 報錯: the page hints you to run sudo chown -R www-data "/var/www/html/reviewboard/htdocs/static/ext"
賦權限後,再次訪問http://192.168.2.249:8060,成功了。
安裝好mod_python後,可以正常訪問網頁了
由於使用的是sqlite數據庫,所以運行命令:
sudo apt-get install sqlite
重啓apache2
sudo systemctl restart apache2
查看端口情況
sudo netstat -apn | grep apache2
7 操作網頁
網上有現成的,可以參考網頁:
https://wenku.baidu.com/view/90c1ed1a773231126edb6f1aff00bed5b9f37373.html
8 配置svn hooks: pre commit
http://pypi.python.org/pypi/reviewboard-svn-hooks
copy到svn倉庫所在的服務器
解壓並進入解壓後的目錄進行安裝:
python setup.py install
安裝成功之後修改如下文件:
/etc/reviewboard-svn-hooks/conf.ini
修改爲:
GNU nano 2.9.3 /etc/reviewboard-svn-hooks/conf.ini Modified
[common]
debug=0
[reviewboard]
url=http://ip:port
username=zhangjing
password=admin
[rule]
min_ship_it_count=2
min_expert_ship_it_count=2
experts=user1,user2
review_path=
ignore_path=
svn hooks配置
pre-commit
修改$REPOS/hooks/下的pri-commit文件內容爲
#!/bin/sh
REPOS="$1"
TXN="$2"
strict_review $REPOS $TXN
exit $?
具體使用請參考第7步。
9 配置svn hooks:post-commit
在 review board所在的服務器上安裝RBTools,如果不行,再把svn所在的服務器上也安裝好RBTools.
sudo pip install RBTools
查看Review board網頁上配置的svn倉庫參數,最好將name與svn倉庫的真實文件夾名稱設置爲一致的。
設置完成後,點擊左側的repositories-->RBTools Setup
找一個linux虛擬機,checkout一套代碼出來。進入代碼目錄,運行腳本命令:
rbt setup-repo
既可創建.reviewboardrc。創建過程中根據提示輸入配置。
REVIEWBOARD_URL = "http://ip:port/"
REPOSITORY = "svn倉庫文件夾名稱"
REPOSITORY_TYPE = "svn"
文件生成後,在此代碼路徑下修改並提交代碼。
然後登陸review board,點擊new review request,選擇已存在的歷史提交。之後填寫Reviewers people,就可以生成Review request了。
參考:
https://www.cnblogs.com/daniaoge/archive/2011/12/29/6161223.html
https://blog.csdn.net/qq_26709459/article/details/80445375
https://blog.csdn.net/u011771638/article/details/36407971