1. Create a service
vi /etc/init.d/sonar
The content is as follows, where the content marked in red is the absolute path of the service:
#!/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
/opt/sonarqube/bin/linux-x86-32/sonar.sh $*
2. Increase the execution authority
chmod +x /etc/init.d/sonar
3. Add service
chkconfig --add sonar
4. Configure the jdk that the service depends on when it starts
vi /opt/sonarqube/conf/wrapper.conf
Modify wrapper.java.command=java and configure it as the absolute path of the java command in jdk
wrapper.java.command=/opt/jdk1.7.0_07/bin/java
5. Start the service
service sonar start