Step One: Create a dedicated account and working directory
AddUser gerrit;passwd Gerrit; create Gerrit dedicated working directory: Mkdir/home/gerrit
Step Two: Configure the Java environment
1 Download jdk:http://download.oracle.com/otn-pub/java/jdk-nb/8u161-8.2/jdk-8u161-nb-8_2-linux-x64.sh from official website
2) Add Execute permission chmod a+x jdk-8u161-nb-8_2-linux-x64.sh, and then run the script installation
3 Set the environment variable, edit the/etc/profile or ~/.BASHRC file to add the following configuration at the end of the file
Export java_home=/usr/local/jdk1.8.0_161
Export Jre_home= $JAVA _home/jre
Export Classpath= $JAVA _home/lib
Export path= $PATH: $JAVA _home/bin: $JRE _home/bin: $CLASSPATH
4 Test the Java environment, in the terminal input: Java-version to see whether the normal display version information, if the installation is successful
Step three: Download installation Gerrit
1 from the official website download gerrit:http://code.google.com/p/gerrit/stored in the/home/gerrit directory
2) Install Gerrit:java-jar Gerrit-full-2.5.2.war init-d review_site, all the way to return, the default installation
3) Modify the Gerrit configuration file, which is described below:
[Gerrit]
BasePath = git//Specifies the location of all Git libraries managed by Gerrit, that is review_site_project/git/
Canonicalweburl = http://192.168.0.20:8081///Specify Web Access Gerrit URL//fill in your own IP and port number
[Database]
Type = h2//Specifies the default database type for Gerrit, you can choose MySQL, install and create Gerrit account
Database = db/reviewdb
[Auth]
Type = HTTP//Specifies the authentication method when the browser logs on Gerrit
[SendEmail]
Enable = True
SmtpServer = smtp.126.com
Smtpserverport = 25
Smtpuser = xxx@126.com
Smtppass = xxx
Sslverify = False
From = codereview<xxx@126.com>
[Container]
user = Gerritserver//Specifies that the identity of the machine on which Gerrit is located corresponds to the user created above
Javahome =/USR/LIB/JVM/JDK7/JRE//system itself with
[SSHD]
ListenAddress = *:29418//Specify the port number on which the SSHD service listens
[HTTPD]
Listenurl = http://*:8081/project//Specify HTTP proxy address
[Cache]
Directory = cache/Cache Location
4 Start Gerrit Service: review_site/bin/gerrit.sh Start | Stop | Restart
If prompted for the following error: * * Error:gerrit_site not set
You can modify the following methods: Vim gerrit.sh
After the Gerrit_site variable is assigned, add the following line to change the value of the variable.
Gerrit_site=/home/gerrit/review_site
5 Boot start: ln-snf/home/gerrit/review_site/bin/gerrit.sh/etc/init.d/gerrit.sh
Step Four: Configure the reverse proxy service (Nginx)
1) Install Nginx reverse proxy Server
Install Gcc:yum Install gcc-c++
Install Pcre:yum install-y pcre pcre-devel
Install Zlib:yum install-y zlib zlib-devel
Install Openssl:yum install-y OpenSSL openssl-devel
Download nginx:https://nginx.org/en/download.html
Install NGINX:TAR-XZVF nginx-1.13.7.tar.gz; CD nginx-1.13.7;./configure; Make Make install
Boot: Add a line to the end of the vi/etc/rc.local file/usr/local/nginx/sbin/nginx
2) Configure nginx:vim/usr/local/nginx/conf/nginx.conf
server {
Listen 80;
server_name localhost;
#charset Koi8-r;
#access_log Logs/host.access.log Main;
Location/{
#root html;
#index index.html index.htm;
Auth_basic "Welcome to Gerrit Code Review!";
AUTH_BASIC_USER_FILE/HOME/GERRIT/GERRIT.PASSWD;
Proxy_pass http://127.0.0.1:8081;
Proxy_set_header x-forwarded-for $remote _addr;
Proxy_set_header Host $host;
}
#error_page 404/404.html;
# REDIRECT Server error pages to the static page/50x.html
#
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
Start Nginx Service:/usr/local/nginx/sbin/nginx
3 Set the first Gerrit user's account number and password
Touch./review_site/etc/passwd
Htpasswd-b./REVIEW_SITE/ETC/PASSWD Gerrit Gerrit
Step five: Test, Access: http://192.168.0.20, login with Gerrit user
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.