ubuntu下安裝sonarqube(團隊程式碼評審工具)
1.先裝好java,mysql,設定JAVA_HOME,JRE_HOME
2.在mysql中建立資料庫和使用者
CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE USER 'sonar' IDENTIFIED BY 'sonar'; GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar'; GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar'; FLUSH PRIVILEGES;
3.下載sonarqube,並解壓,移動到opt目錄
wget http://dist.sonar.codehaus.org/sonarqube-5.1.zip
unzip sonarqube-5.1.zip
mv sonarqube-5.1 /opt/sonar
4.編輯sonarqube.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在/opt/sonar/conf/wrapper.conf檔案中修改java路徑
# Path to JVM executable. By default it must be available in PATH.
# Can be an absolute path, for example:
#wrapper.java.command=/path/to/my/jdk/bin/java
wrapper.java.command=/software/jdk1.8.0_65/bin/java
啟動sonar:
sudo /etc/init.d/sonar start
停止sonar
sudo /etc/init.d/sonar stop重啟sonar
sudo /etc/init.d/sonar restart
開啟瀏覽器輸入:http://ip地址:9000/sonar/
登入,之後在update center中安裝相關外掛