2019/06/14

How to install SonarQube 7.x on Ubuntu 18.04

Install required package
apt update && sudo apt upgrade -y
apt install -y unzip curl openjdk-8-jdk-headless mysql-server

Create Database
mysql -uroot -p
CREATE DATABASE sonarqube;
CREATE USER sonarqube@'localhost' IDENTIFIED BY 'sonarqube';
GRANT ALL ON sonarqube.* to sonarqube@'localhost';
FLUSH PRIVILEGES;
\q

Download and install SonarQube
mkdir /opt/sonarqube
cd /opt/sonarqube
wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-7.7.zip
unzip sonarqube-7.7.zip
chown -R username:password /opt/sonarqube
nano sonarqube-7.7/conf/sonar.properties

sonar.jdbc.username=sonarqube
sonar.jdbc.password=sonarqube
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonarqube?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
sonar.web.javaOpts=-Xmx1024m -Xms512m -XX:+HeapDumpOnOutOfMemoryError
sonar.web.javaAdditionalOpts=-server

Add SonarQube service
nano /etc/systemd/system/sonarqube.service

[Unit]
Description=SonarQube service
After=syslog.target network.target

[Service]
Type=forking

ExecStart=/opt/sonarqube/sonarqube-7.7/bin/linux-x86-64/sonar.sh start
ExecStop=/opt/sonarqube/sonarqube-7.7/bin/linux-x86-64/sonar.sh stop

User=username
Group=sudo
Restart=always

[Install]
WantedBy=multi-user.target

service sonarqube start
service sonarqube status
systemctl enable sonarqube

Test
curl http://localhost:9000
Login info
username = admin
password = admin

沒有留言:

張貼留言