- 1、创建服务
vi /etc/init.d/sonar
内容如下,其中标红内容为服务绝对路径:
#!/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  
/app/sonarqube-7.6/bin/linux-x86-64/sonar.sh $* 
- 2、增加执行权限
chmod +x /etc/init.d/sonar
- 3、添加服务
chkconfig --add sonar
- 4、配置服务启动时依赖的jdk
vim /app/sonarqube-7.6/conf/wrapper.conf
修改wrapper.java.command=java,配置为jdk中java命令的绝对路径
wrapper.java.command=/app/jdk1.8.0_144/bin/java
- 5、启动服务
service sonar start