sudo mkdir /opt/sonarqube
Step 2: Once the directory is created, update the permissions so that the sonarqube user will be able to read and write files in this directory:
sudo chown -R sonarqube:sonarqube /opt/sonarqube
Step 3: SonarQube releases are packaged in a zipped format, so install the unzip utility using your package manager so you can extract the distribution files:
sudo apt-get install unzip
Step 4: Next, we need to create a database and credentials that SonarQube will use. Log in to the MySQL server as the root user:
mysql -u root -p
mysql> CREATE DATABASE sonar;
mysql> EXIT;
mysql> CREATE USER sonar@localhost IDENTIFIED BY 'some_secure_password';
mysql> GRANT ALL ON sonar.* to sonar@localhost;
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
Start by changing the current working directory to the SonarQube installation directory:
cd /opt/sonarqube
Step 9: Then, head over to the SonarQube downloads page and grab the download link for SonarQube 7.0. There are two versions of SonarQube available for download on the page, but in this specific tutorial we'll be using SonarQube 7.0.
wget --header "Cookie: oraclelicense=accept-securebackup-cookie" https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-7.6.zip
sudo unzip sonarqube-7.0.zip
Step 11: Once the files extract, delete the downloaded zip file, as you no longer need it: (Optional)
sudo rm sonarqube-7.0.zip
Now that all the files are in place, it's time to configure SonarQube.
We'll need to edit a few things in the SonarQube configuration file. Namely:
We need to specify the username and password that the SonarQube server will use for the database connection.
We also need to tell SonarQube to use MySQL for our backend database.
We'll tell SonarQube to run in server mode, which will yield improved performance.
-
sonar.jdbc.username=sonar
-
sonar.jdbc.password=sonar
(your own password) -
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
Uncomment this line -
sonar.web.host=0.0.0.0
Uncomment this line -
sonar.web.context=/sonar
(Optional)