Install and Configure Sonarqube Server on Ubuntu 14.04

Опубликовано: 15 Октябрь 2024
на канале: Self Learning
17,804
75

Installing SonarQube on Ubuntu

Create SonarQube database and user
First run MySQL through terminal:

mysql -u root -p

Then create database and user:
mysql -u root -p

-- Create a new sonar database
CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;

-- Create a local and a remote user
CREATE USER sonar@localhost IDENTIFIED BY 'sonar';
CREATE USER sonar@'%' IDENTIFIED BY 'sonar';

-- Grant users permissions
GRANT ALL ON sonar.* TO sonar@localhost;
GRANT ALL ON sonar.* TO sonar@'%';

-- Check the results then exit
use mysql
SELECT * FROM user WHERE User='sonar'\G
SELECT * FROM db WHERE User='sonar'\G
QUIT
FLUSH PRIVILEGES;

Download and unzip SonarQube distribution
wget http://dist.sonar.codehaus.org/sonarq...
unzip sonarqube-5.1.zip
mv sonarqube-5.1 /opt/sonar
Edit sonar.properties
Open /opt/sonar/conf/sonar.properties with your favourite text editor, and modify it.

MySQL settings
Uncomment the user credentials and the MySQL related settings

sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance

Web Server settings
The following settings allow you to run the server on page

http://localhost:9000/sonar
sonar.web.host=0.0.0.0
sonar.web.context=/sonar
sonar.web.port=9000

Implement SonarQube server as a service [optional]
Copy sonar.sh to etc/init.d/sonar and modify it according to your platform.
sudo cp bin/linux-x86-64/sonar.sh /etc/init.d/sonar
sudo gedit /etc/init.d/sonar

Insert two new lines:
SONAR_HOME=/opt/sonar
PLATFORM=linux-x86-64

Modify the following lines:
WRAPPER_CMD="${SONAR_HOME}/bin/${PLATFORM}/wrapper"
WRAPPER_CONF="${SONAR_HOME}/conf/wrapper.conf"
PIDDIR="/var/run"

Register as a Linux service:
sudo update-rc.d -f sonar remove
sudo chmod 755 /etc/init.d/sonar
sudo update-rc.d sonar defaults

Run SonarQube server
sudo /etc/init.d/sonar start