{"id":5409,"date":"2014-11-24T14:22:57","date_gmt":"2014-11-24T20:22:57","guid":{"rendered":"https:\/\/secure.rosehosting.com\/blog\/?p=5409"},"modified":"2022-12-09T06:07:23","modified_gmt":"2022-12-09T12:07:23","slug":"how-to-install-gerrit2-on-a-centos-7-linux-vps","status":"publish","type":"post","link":"https:\/\/www.rosehosting.com\/blog\/how-to-install-gerrit2-on-a-centos-7-linux-vps\/","title":{"rendered":"How to install Gerrit2 on CentOS 7"},"content":{"rendered":"
<\/p>\n
How to install Gerrit2 on CentOS 7.\u00a0Gerrit\u00a0<\/strong>\u00a0is a web based code review application which uses the Git version control system. Gerrit makes code review easier by generating the code changes in a side-by-side preview, allowing inline comments that can be added by a reviewer. Gerrit allows any authorized user to submit changes to the master Git repository, which simplifies the process when an approved change has to be merged in manually by the project maintainer.<\/p>\n System requirements?<\/strong><\/p>\n <\/p>\n First thing to do, is to install git and vim<\/p>\n Next, JAVA is required for Gerrit installation, and you can download the latest version of JAVA easily<\/a>. At the time of writing this article the latest version of JAVA is 8u25 and can be downloaded and installed using the following commands:<\/p>\n once the JAVA package has been downloaded, install it using for 32bit systems use:<\/p>\n for 64bit systems use:<\/p>\n configure the JAVA package using check the JAVA version running on your system:<\/p>\n Install MariaDB, the default databases server in CentOS 7 which is a drop-in-replacement for MySQL using Once installed, edit its server configuration file in Start and add MariaDB to your system’s startup using Optionally but recommended, run You have to create a user and database and grant privileges on the database to the newly created user. You can achieve this using the following commands:<\/p>\n Gerrit stores configuration files, the server’s SSH keys and the managed Git repositories under a local directory. It’s recommended to run Gerrit Code Review as a separate user account on the system, so let’s first create a new user and login with the newly created user:<\/p>\n You can download gerrit using the command below:<\/p>\n once the gerrit2 war file has been downloaded and you’re logged in as fill the questions asked by the wizard, for example:<\/p>\n next, run the following command to rebuilt the gerrit index:<\/p>\n and start the gerrit using the command below:<\/p>\n exit to root by executing the <\/p>\n Install Apache using Add the following to Restart Apache and add it to automatically start on your system start-up using:<\/p>\n <\/p>\n create user using restart apache using<\/p>\n next, navigate to http:\/\/your_hostname\/gerrit\/ and you should get the Gerrit review application loaded in your browser.<\/p>\n Of course you don\u2019t have to\u00a0install Gerrit2 on CentOS 7,\u00a0 if you use one of our CentOS VPS Hosting<\/a> services, in which case you can simply ask our expert Linux admins to install Gerrit2 on CentOS 7 for you. They are available 24\u00d77 and will take care of your request immediately.<\/p>\n PS<\/span>.<\/strong> If you liked this post on how to install Gerrit2 on CentOS 7, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":" How to install Gerrit2 on CentOS 7.\u00a0Gerrit\u00a0\u00a0is a web based code review application which uses the Git version control system. … <\/p>\n\n
1. UPDATE SYSTEM<\/b><\/h3>\n
SSH<\/code> to your server, initiate a
screen<\/code> session and make sure your CentOS 7 VPS<\/a> is fully up-to-date by running:<\/p>\n
## screen -U -S gerrit-screen\r\n## yum update<\/pre>\n
## yum install git vim<\/pre>\n
2. INSTALL JAVA<\/b><\/h3>\n
for 64-bit systems:<\/h4>\n
## wget --no-cookies \\\r\n--no-check-certificate \\\r\n--header \"Cookie: oraclelicense=accept-securebackup-cookie\" \\\r\n\"http:\/\/download.oracle.com\/otn-pub\/java\/jdk\/8u25-b17\/jdk-8u25-linux-x64.rpm\" \\\r\n-O \/opt\/jdk-8-linux-x64.rpm<\/pre>\n
for 32-bit systems:<\/h4>\n
## wget --no-cookies \\\r\n--no-check-certificate \\\r\n--header \"Cookie: oraclelicense=accept-securebackup-cookie\" \\\r\n\"http:\/\/download.oracle.com\/otn-pub\/java\/jdk\/8u25-b17\/jdk-8u25-linux-i586.rpm\" \\\r\n-O \/opt\/jdk-8-linux-i586.rpm<\/pre>\n
yum<\/code> as follows:<\/p>\n
## yum install \/opt\/jdk-8-linux-i586.rpm<\/pre>\n
## yum install \/opt\/jdk-8-linux-x64.rpm<\/pre>\n
alternatives<\/code> as in:<\/p>\n
## JDK_DIRS=($(ls -d \/usr\/java\/jdk*))\r\n## JDK_VER=${JDK_DIRS[@]:(-1)}\r\n\r\n## alternatives --install \/usr\/bin\/java java \/usr\/java\/\"${JDK_VER##*\/}\"\/jre\/bin\/java 20000\r\n## alternatives --install \/usr\/bin\/jar jar \/usr\/java\/\"${JDK_VER##*\/}\"\/bin\/jar 20000\r\n## alternatives --install \/usr\/bin\/javac javac \/usr\/java\/\"${JDK_VER##*\/}\"\/bin\/javac 20000\r\n## alternatives --install \/usr\/bin\/javaws javaws \/usr\/java\/\"${JDK_VER##*\/}\"\/jre\/bin\/javaws 20000\r\n## alternatives --set java \/usr\/java\/\"${JDK_VER##*\/}\"\/jre\/bin\/java\r\n## alternatives --set javaws \/usr\/java\/\"${JDK_VER##*\/}\"\/jre\/bin\/javaws\r\n## alternatives --set javac \/usr\/java\/\"${JDK_VER##*\/}\"\/bin\/javac\r\n## alternatives --set jar \/usr\/java\/\"${JDK_VER##*\/}\"\/bin\/jar<\/pre>\n
## java -version<\/pre>\n
3. INSTALL MARIADB (MYSQL)<\/b><\/h3>\n
yum<\/code>:<\/p>\n
## yum install mariadb mariadb-server mysql<\/pre>\n
\/etc\/my.cnf.d\/server.cnf<\/code> and add the following:<\/p>\n
## vim \/etc\/my.cnf.d\/server.cnf\r\n\r\n[mysqld]\r\n#log-bin=mysql-bin\r\n#binlog_format=mixed\r\nbind-address = 127.0.0.1<\/pre>\n
systemctl<\/code>:<\/p>\n
## systemctl restart mariadb\r\n## systemctl status mariadb\r\n## systemctl enable mariadb<\/pre>\n
mysql_secure_installation<\/code> to finialize MariaDB setup:<\/p>\n
## mysql_secure_installation\r\n\r\nEnter current password for root (enter for none): ENTER\r\nSet root password? [Y\/n] Y\r\nRemove anonymous users? [Y\/n] Y\r\nDisallow root login remotely? [Y\/n] Y\r\nRemove test database and access to it? [Y\/n] Y\r\nReload privilege tables now? [Y\/n] Y<\/pre>\n
4. INSTALL GERRIT<\/b><\/h3>\n
Create a database<\/h4>\n
## mysql -u root -p\r\n\r\nMariaDB> create database gerritdb;\r\nMariaDB> grant all on gerritdb.* to gerrit@localhost identified by 'secret';\r\n<\/pre>\n
Initialize the Site<\/h4>\n
## useradd -m gerrit2\r\n## su - gerrit2<\/pre>\n
Download gerrit<\/h4>\n
## wget https:\/\/gerrit-releases.storage.googleapis.com\/gerrit-2.9.1.war -O \/home\/gerrit2\/gerrit.war<\/pre>\n
gerrit2<\/code>, run the following command to initialize a new site directory:<\/p>\n
## java -jar gerrit.war init -d \/home\/gerrit2\/review_site<\/pre>\n
Location of Git repositories [git]: \r\nDatabase server type [mysql]: \r\nServer hostname [localhost]: \r\nServer port [(mysql default)]: \r\nDatabase name [gerritdb]: \r\nDatabase username [gerrit]: \r\nChange gerrit's password [y\/N]? n \r\nType [LUCENE\/?]: \r\nAuthentication method [HTTP\/?]: \r\nGet username from custom HTTP header [y\/N]? \r\nSSO logout URL : \r\nInstall Verified label [y\/N]? \r\nSMTP server hostname [localhost]: \r\nSMTP server port [(default)]: \r\nSMTP encryption [NONE\/?]: \r\nSMTP username : \r\nRun as [gerrit2]: \r\nJava runtime [\/usr\/java\/jdk1.8.0_25\/jre]: \r\nUpgrade \/home\/gerrit2\/review_site\/bin\/gerrit.war [Y\/n]? \r\nCopying gerrit.war to \/home\/gerrit2\/review_site\/bin\/gerrit.war\r\nListen on address [*]: \r\nListen on port [29418]: \r\nBehind reverse proxy [Y\/n]? \r\nProxy uses SSL (https:\/\/) [y\/N]? \r\nSubdirectory on proxy server [\/gerrit\/]: \r\nListen on address [*]: \r\nListen on port [8081]: \r\nCanonical URL [http:\/\/vs377.rosehosting.com\/gerrit\/]: \r\nInstall plugin commit-message-length-validator version v2.9.1 [y\/N]? \r\nInstall plugin download-commands version v2.9.1 [y\/N]? \r\nInstall plugin replication version v2.9.1 [y\/N]? \r\nInstall plugin reviewnotes version v2.9.1 [y\/N]? \r\nInstall plugin singleusergroup version v2.9.1 [y\/N]? \r\n\r\nInitialized \/home\/gerrit2\/review_site<\/pre>\n
## java -jar gerrit.war reindex -d \/home\/gerrit2\/review_site<\/pre>\n
## \/home\/gerrit2\/review_site\/bin\/gerrit.sh start<\/pre>\n
exit<\/code> command.<\/p>\n
5. INSTALL APACHE<\/b><\/h3>\n
yum<\/code>:<\/p>\n
## yum install httpd httpd-tools openssl mod_ssl<\/pre>\n
\/etc\/httpd\/conf.d\/options.conf<\/code><\/p>\n
## vim \/etc\/httpd\/conf.d\/options.conf\r\n\r\nTraceEnable off\r\n\r\n## Disable Signature\r\nServerSignature Off\r\n\r\n## Disable Banner\r\nServerTokens Prod<\/pre>\n
## vim \/etc\/httpd\/conf.d\/vhosts.conf\r\n\r\n# Load my vhosts\r\nIncludeOptional vhosts.d\/*.conf<\/pre>\n
## mkdir \/etc\/httpd\/vhosts.d<\/pre>\n
## systemctl restart httpd\r\n## systemctl status httpd\r\n## systemctl enable httpd<\/pre>\n
6. APACHE PROXY TO GERRIT<\/b><\/h3>\n
## vim \/etc\/httpd\/vhosts.d\/gerrit.conf\r\n\r\n<VirtualHost your_ip_address:80>\r\n ServerName your_hostname\r\n\r\n ProxyRequests Off\r\n ProxyVia Off\r\n ProxyPreserveHost On\r\n\r\n <Proxy *>\r\n\t\tOrder deny,allow\r\n\t\tAllow from all\r\n <\/Proxy>\r\n\r\n <Location \/gerrit\/login\/>\r\n\t\tAuthType Basic\r\n\t\tAuthName \"Gerrit Code Review\"\r\n\t\tRequire valid-user\r\n\t\tAuthUserFile '\/etc\/httpd\/gerrit.htpasswd'\r\n <\/Location>\r\n\r\n AllowEncodedSlashes On\r\n ProxyPass \/gerrit\/ http:\/\/your_ip_address:8081\/gerrit\/\r\n<\/VirtualHost><\/pre>\n
htpasswd<\/code><\/p>\n
## htpasswd -c \/etc\/httpd\/gerrit.htpasswd admin\r\nNew password: \r\nRe-type new password: \r\nAdding password for user admin<\/pre>\n
## systemctl restart httpd<\/pre>\n
What’s Next?<\/h3>\n
\n