http://blog.csdn.net/dfhuang09/article/details/54730119
sudo apt-get install apache2
安装完成启动是若出现如下警告:(并不存在实际问题,可以选择忽略)
* Starting web server apache2
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
通过编辑下面的文件,在文件末尾添加一行内容sudo vim /etc/apache2/apache2.conf
ServerName localhost #添加的内容
再重启 apache 服务即可消除该警告。管理apache服务的常用命令如下:
sudo service apache2 start/stop/restart #启动/停止/重启apache2
sudo adduser gerrit #这一步根据提示输入密码并确认信息
sudo su gerrit
cd
可以自己选择安装包版本,这里以"gerrit-2.13.8.war"为例
wget http://gerrit-releases.storage.googleapis.com/gerrit-2.13.8.war
java -jar gerrit-2.13.8.war init -d review_site
这里我们可以一路回车,以默认的配置完成安装。后面可以对相关文件修改进行配置操作。
vim ~/review_site/etc/gerrit.config
关于认证方式,还可以有 openid, LDAP 等方式,这里采用了 http 方式。这种认证方式下,登陆 gerrit 后会发送邮件至用户邮箱来确认邮箱地址。其缺点是口令文件管理需手动维护;另外登陆成功后切换用户或退出比较麻烦,无法直接退出,除非使用 http://nobody:worngpass@localhost:port/ (假设原本登陆地址是http://localhost:port/)。
若出现以下错误,很可能是其中的“sendemail”配置存在问题
安装所需的一些工具
sudo apt-get install apache2.2-bin apache2-utils apache2-mpm-worker
创建口令文件,并添加 gerrit 登陆用户
sudo htpasswd -cb /etc/apache2/passwords gerrit gerrit #其中-c参数加路径用于在指定位置创建口令文件,仅第一次建用户需-c
后续再添加其他用户时,可用下面的命令
sudo htpasswd /etc/apache2/passwords #注意文件的位置要与上面的对应,然后按提示设置密码
编辑下面文件,新增监听端口(“Listen 1998”)
sudo vim /etc/apache2/ports.conf
打开所需的 module
cd /etc/apache2/mods-enabled
ln -s /etc/apache2/mods-available/proxy.conf proxy.conf
ln -s /etc/apache2/mods-available/proxy.load proxy.load
ln -s /etc/apache2/mods-available/proxy_http.load proxy_http.load
配置 Apache 服务器
sudo vim /etc/apache2/sites-enabled/000-default.conf
添加以下内容至该文件:(后面遇到问题后做了一定的修改)
sudo ln -snf /home/gerrit/review_site/bin/gerrit.sh /etc/init.d/gerrit.sh
sudo ln -snf /etc/init.d/gerrit.sh /etc/rc2.d/S90gerrit
sudo ln -snf /etc/init.d/gerrit.sh /etc/rc3.d/S90gerrit
自启动脚本需要一些缺省配置,故需创建下面的文件
sudo /etc/default/gerritcodereview
GERRIT_SITE=/home/gerrit/review_site
NO_START=0
sudo service apache2 restart
~/review_site/bin/gerrit.sh start #此命令在gerrit用户下执行
ssh -p 29418 10.239.54.6 gerrit ls-projects #没有问题就会列出所有的project
git clone ssh://[email protected]:29418/REPOSITORY_NAME.git #没有问题就可以以此命令获取gerrit上的 project 了
gerrit@husanlim:~$ ssh -p 29418 [email protected] gerrit gsql
fatal: gerrit does not have "Access Database" capability.
gerrit@husanlim:~$ ~/review_site/bin/gerrit.sh stop
gerrit@husanlim:~$ java -jar gerrit-2.13.8.war gsql -d ./review_site/
常用的一些数据库管理命令:
gerrit> show tables;
gerrit> show columns from system_config;
gerrit> select * from ACCOUNTS;
gerrit> delete from ACCOUNT_EXTERNAL_IDS where email_address='[email protected]';
gerrit> update accounts set full_name='admin' where full_name='gerrit';
http://builds.quelltextlich.at/gerrit/nightly/master/latest-ok/index.html
停掉 gerrit 服务,运行下面的命令即可:(建议不要直接下载插件包放到 plugins 目录,很容易会出现问题)
gerrit@husanlim:~$ review_site/bin/gerrit.sh stop
gerrit@husanlim:~$ java -jar gerrit-2.13.8.war init -d review_site/ --batch --install-plugin commit-message-length-validator
gerrit@husanlim:~$ java -jar gerrit-2.13.8.war init -d review_site/ --batch --install-plugin download-commands
gerrit@husanlim:~$ java -jar gerrit-2.13.8.war init -d review_site/ --batch --install-plugin hooks
gerrit@husanlim:~$ java -jar gerrit-2.13.8.war init -d review_site/ --batch --install-plugin replication
gerrit@husanlim:~$ java -jar gerrit-2.13.8.war init -d review_site/ --batch --install-plugin reviewnotes
gerrit@husanlim:~$ java -jar gerrit-2.13.8.war init -d review_site/ --batch --install-plugin singleusergroup
ssh -p 29418 [email protected] gerrit plugin ls
ssh -p 29418 [email protected] gerrit plugin remove download-commands
这里可能会遇到下面的错误:
fatal: remote plugin administration is disabled
需要在 gerrit.config 中添加如下配置
网页上 create project 不能创建多级目录,报错 “404 Not Found” ;或者命令创建 project 后无法访问, 报错 “The page you requested was not found, or you do not havepermission to view this page.” 。
这主要是由 URL 路径编码的问题造成的,需要 apache 服务器允许对 URL 中路径分隔符进行编码,修改 apache2 的配置
sudo vim /etc/apache2/sites-available/000-default.conf
重启 apache 后问题就能解决了。
http://www.worldhello.net/gotgit/05-git-server/055-gerrit.html