CentOS7 build gerrit code review service method

Step 1: Create a dedicated account and working directory

adduser gerrit; passwd gerrit; create a dedicated working directory for gerrit: mkdir /home/gerrit

Step 2: Configure the Java environment

1 ) Download the JDK from the official website: http://download.oracle.com/otn-pub/java/jdk-nb/8u161-8.2/jdk-8u161-nb-8_2-linux-x64.sh

**2 ) Add execution permission chmod a+x jdk-8u161-nb-8_2-linux-x64.sh, and then run the script to install **

3 ) Set environment variables, edit /etc/profile or ~/.bashrc file and 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 ) To test the Java environment, enter: java -version in the terminal to see if the version information is displayed normally, if it is displayed, the installation is successful

Step 3: Download and install gerrit

1) Download gerrit from the official website: 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, press enter all the way, install by default

3) Modify the gerrit configuration file, the description is as follows:

[ gerrit]
 basePath = git   //Specify the location of all git repositories managed by gerrit, that is, review_site_project/git/
 canonicalWebUrl = http://192.168.0.20:8081///Specify the URL for web access to gerrit//Fill in your own ip and port number[database]
 type = h2     //Specify the default database type of gerrit, you can choose mysql, install and create a gerrit account
 database = db/ReviewDB   
[ auth]
 type = HTTP  //Specify the authentication method when the browser logs in to gerrit[sendemail]
 enable =true
 smtpServer = smtp.126.com
 smtpServerPort =25
 smtpUser = [email protected]
 smtpPass = xxx
 sslVerify =falsefrom= CodeReview<[email protected]>[container]
 user = gerritserver            //Specify the user identity of the machine where gerrit is located corresponds to the user created above
 javaHome =/usr/lib/jvm/jdk7/jre      //The system itself[sshd]
 listenAddress =*:29418//Specify the port number that the sshd service listens to[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 the following error occurs: ** ERROR: GERRIT_SITE not set

You can modify it as follows: vim gerrit.sh

Add the following line after the GERRIT_SITE variable is assigned 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 4: Configure 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 up: add a line /usr/local/nginx/sbin/nginx at the end of vi /etc/rc.local file

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  500502503504/50x.html;
 location =/50x.html {
  root  html;}

Start Nginx service: /usr/local/nginx/sbin/nginx

3 ) Set the account and password of the first gerrit user

touch ./review_site/etc/passwd
htpasswd -b ./review_site/etc/passwd gerrit gerrit

Step 5: Test, visit: http://192.168.0.20, log in as user gerrit

The above method of setting up a gerrit code review service on CentOS7 is all the content shared by the editor. I hope to give you a reference.

Recommended Posts

CentOS7 build gerrit code review service method
Centos7 build DNS service
CentOs7.3 build RabbitMQ 3.6 stand-alone service
CentOs7.3 build SolrCloud cluster service
Centos6 method steps to build gitlab
Build WeChat applet service based on CentOS
Build WeChat applet service based on CentOS
CentOS7 build jenkins
Centos7 build python3.8.5+scrapy+gerapy
CentOS7.3 64 bit, build Zabbix3.4
CentOS 8 enable NTP service
Linux (centos7) build gitlab
Build k8s1.9.9 on centos7
CentOS6.7 build LNMP environment
Centos6.9 build rabbitmq 3.6.8 cluster
CentOS 7 install Docker service
Centos7.6 build LNMP environment
CentOS 7 deploys RabbitMQ service
CentOS 7 deploy saltstack service
Centos7 build Kubernetes cluster
Jenkins build on centos
Build Hadoop in CentOS
CentOS7 deploys NFS service
Centos6.8 deploy vnc service
Docker CentOS installation method
CentOS 7 build LNMP environment