发布网友 发布时间:2022-04-07 21:08
共2个回答
懂视网 时间:2022-04-08 01:29
apt-get install gitUbuntu14.10及以上版本的Ubuntu官方软件中心里有OpenJDK java 8,可以直接用apt-get安装,低版本得从PPA(Personal Package Archives 个人软件包集)中安装。
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk
配置Java环境变量
vi /etc/profile
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_21
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
source /etc/profile
java -version
如果安装了多个jdk,就选择一个默认的
sudo update-alternatives --config java
sudo update-alternatives --config java
sudo apt-get install postgresql
初次安装后,会默认生成名为postgres的Linux系统用户、数据库和数据库用户(作为数据库管理员),首先修改postgres数据库用户的密码,然后增加Gerrit需要的数据库
sudo -u postgres psql
postgres=# password postgres
(input password twice)
postgres=# q
sudo -u postgres createuser -RDIElPS gerrit2
sudo -u postgres psql
postgres=# password gerrit2
(input password twice)
sudo -u postgres createdb -E UTF-8 -O gerrit2 reviewdb
从官网下载Gerrit的安装包,为了方便改名为gerrit.war,建议创建一个Linux用户来安装,本人安装在gerrit2用户的review_site目录下
sudo adduser gerrit2
sudo su gerrit2
java -jar gerrit.war init -d /home/gerrit2/review_site
然后就会进行很多配置,大部分默认即可,要注意的是数据库和身份认证,这些配置也可以在安装完成后在~/review_site/etc/gerrit.config文件中修改。
以下是别人的配置,他是用MySQL+Nginx做HTTP认证,这里贴出来只是让大家看下大概的安装步骤,仅供参考:
# java -jar gerrit-2.8.war init -d /etc/gerrit/
*** Gerrit Code Review 2.8
***
Create ‘/etc/gerrit‘ [Y/n]? y
*** Git Repositories
***
Location of Git repositories [git]:
*** SQL Database
***
Database server type [h2]: mysql
Gerrit Code Review is not shipped with MySQL Connector/J 5.1.21
** This library is required for your configuration. **
Download and install it now [Y/n]? y
Downloading http://repo2.maven.org/maven2/mysql/mysql-connector-java/5.1.21/mysql-connector-java-5.1.21.jar ... OK
Checksum mysql-connector-java-5.1.21.jar OK
Server hostname [localhost]:
Server port [(mysql default)]:
Database name [reviewdb]: gerritdb
Database username [root]: gerrituser
gerrituser‘s password :
confirm password :
*** User Authentication
***
Authentication method [OPENID/?]: http
Get username from custom HTTP header [y/N]? n
SSO logout URL :
*** Email Delivery
***
SMTP server hostname [localhost]: smtp.googlemail.com
SMTP server port [(default)]: 587
SMTP encryption [NONE/?]: tls
SMTP username [root]: gerrit@thstack.com
review@thstack.com‘s password :
confirm password :
*** Container Process
***
Run as [root]:
Java runtime [/usr/lib/jvm/java-6-openjdk-amd64/jre]:
Copy gerrit-2.8.war to /etc/gerrit/bin/gerrit.war [Y/n]? y
Copying gerrit-2.8.war to /etc/gerrit/bin/gerrit.war
*** SSH Daemon
***
Listen on address [*]:
Listen on port [29418]:
Gerrit Code Review is not shipped with Bouncy Castle Crypto v144
If available, Gerrit can take advantage of features
in the library, but will also function without it.
Download and install it now [Y/n]? y
Downloading http://www.bouncycastle.org/download/bcprov-jdk16-144.jar ... OK
Checksum bcprov-jdk16-144.jar OK
Generating SSH host key ... rsa... dsa... done
*** HTTP Daemon
***
Behind reverse proxy [y/N]? y
Proxy uses SSL (https://) [y/N]? n
Subdirectory on proxy server [/]:
Listen on address [*]:
Listen on port [8081]: 8082
Canonical URL [http://www.thstack.com/]: http://review.thstack.com/
*** Plugins
***
Install plugin reviewnotes version v2.8 [y/N]? y
Install plugin download-commands version v2.8 [y/N]? y
Install plugin replication version v2.8 [y/N]? y
Install plugin commit-message-length-validator version v2.8 [y/N]? y
Initialized /etc/gerrit
Executing /etc/gerrit/bin/gerrit.sh start
Starting Gerrit Code Review: OK
Waiting for server on review.thstack.com:80 ... OK
Opening http://review.thstack.com/#/admin/projects/ ...FAILED
Open Gerrit with a JavaScript capable browser:
http://review.thstack.com/#/admin/projects/
我试过用Apache做反向代理,需要配置不过配置~/review_site/etc/gerrit.config还有/etc/apache2/httpd.conf,还是有点问题,总是报Authorization header的错误,最后选择了LDAP认证,LDAP服务器是公司已经搭好的,直接用了。
最后,我的~/review_site/etc/gerrit.config如下:
[gerrit]
basePath = git
canonicalWebUrl = https://localhost:8080
[database]
type = postgresql
hostname = localhost
database = reviewdb
username = gerrit2
[auth]
type = LDAP
[ldap]
server = ldaps://xx:xx
accountBase = xx
accountPattern = (&(objectClass=person)(uid=${username}))
accountFullName = cn
accountEmailAddress = mail
accountSshUserName = uid
referral = follow
groupBase = xx
groupScope = one
[sendemail]
smtpServer = localhost
from = ${user} [review] <xx@xx.com>
[container]
user = gerrit
javaHome = /usr/lib/jvm/java-8-openjdk-amd64/jre
[sshd]
listenAddress = *:29418
[download]
scheme = ssh
scheme = http
[httpd]
listenUrl = proxy-http://localhost:8080
[cache]
directory = cache
[http]
proxy = http://xx:xx
[gitweb]
cgi = /usr/lib/cgi-bin/gitweb.cgi
[cache "web_sessions"]
maxAge = 1 month
配置好后,启动Gerrit,需要用绝对路径
/home/gerrit2/review_site/bin/gerrit.sh start
在浏览器输入 http://localhost:8080 弹出Gerrit的页面,终于成功了!
Gerrit服务器的搭建(Git+Gerrit+PostgreSQL+LDAP)
标签:
热心网友 时间:2022-04-07 22:37
似乎就是那么慢的, 你调试完后不要关闭模拟器窗口, 代码修改完后直接 run 应该可以的