1. Download and unzip the SonarQube distribution
2. Starting the Web Server
The default port is "9000" and the context path is "/". These values can be changed in <install_directory>/conf/sonar.properties:
sonar.properties
sonar.web.host=192.0.0.1
sonar.web.port=80
sonar.web.context=/sonar
Execute the following script to start the server:
• On Linux/Mac OS: bin/<YOUR OS>/sonar.sh start
• On Windows: bin/windows-x86-XX/StartSonar.bat
3. Running SonarQube as a Service
On Windows
Install/uninstall NT service (may have to run these files via Run As Administrator):
<install_directory>/bin/windows-x86-XX/InstallNTService.bat
<install_directory>/bin/windows-x86-XX/UninstallNTService.bat
Start/stop the service:
<install_directory>/bin/windows-x86-XX/StartNTService.bat
<install_directory>/bin/windows-x86-XX/StopNTService.bat
Tuning the Web Server
By default, SonarQube is configured to run on any computer with a simple Java JRE.
For better performance, the first thing to do when installing a production instance is to use a Java JDK and activate the server mode by uncommenting/setting the following line in <install_directory>/conf/wrapper.conf:
wrapper.java.additional.6=-server
On Linux
Create the file /etc/init.d/sonar with this content:
#!/bin/sh
#
# rc file for SonarQube
#
# chkconfig: 345 96 10
# description: SonarQube system (www.sonarsource.org)
#
### BEGIN INIT INFO
# Provides: sonar
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: SonarQube system (www.sonarsource.org)
# Description: SonarQube system (www.sonarsource.org)
### END INIT INFO
/usr/bin/sonar $*
Register SonarQube at boot time (RedHat, CentOS, 64 bit):
sudo ln -s <install_directory>/bin/linux-x86-64/sonar.sh /usr/bin/sonar
sudo chmod 755 /etc/init.d/sonar
sudo chkconfig --add sonar
FAQ
Failed to launch the SonarQube service on Windows platform with a LocalSystem account
modify "conf/wrapper.conf" and specify "java.io.tmpdir" as like
"wrapper.java.additional.7=-Djava.io.tmpdir= C:/Users/xxx/AppData/Local/Temp"
Or
Add Environment var: SONAR_USER_HOME
注意:执行sonar分析时会在此目录的cache文件夹保存临时文件,因此必须要有写权限,否则会报以下异常
Can not execute SonarQube analysis: Fail to download libraries from server