基础信息
1、官网:
https://www.sonarqube.org/
下载:
wget https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-7.1.zip
解压
unzip sonarqube-7.1.zip
2、本地服务器环境:
3、mysql 配置
mysql> CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql> CREATE USER 'sonar' IDENTIFIED BY 'sonar';
mysql> GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
mysql> GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';
mysql> FLUSH PRIVILEGES;
4、sonar 配置
vim /data/sonarqube-7.1/conf/sonar.properties
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
sonar.web.host=0.0.0.0 // 默认所有IP可访问
sonar.web.port=9001 // 默认端口因为默认端口9000已被PHP占用
sonar.search.port=9002
5、配置nginx
server {
listen 80;
server_name sonar.blkid.cn;
location / {
proxy_pass http://127.0.0.1:9001;
root /data/sonarqube-7.1/;
}
}
nginx 重载
nginx -s reload
6、启动服务
sh /data/sonarqube-7.1/bin/linux-x86-64/sonar.sh start
7、sonar汉化
https://github.com/SonarQubeCommunity/sonar-l10n-zh/releases
下载jar安装包,将文件放置在 /data/sonarqube-7.1/extensions/plugins
并进行重启sonar
注意:
1.在配置过程中不可以使用root用户
2.注意Java版本
3.注意端口号被占用问题
查看端口号是否被占用
lsof -i:9000
netstat -anp|grep 80
ps -aux |grep sonar