How to Install and configure Sonarqube on Linux (RHEL/Centos/ec2)

Sonarqube is a great tool for source code quality management, code analysis etc. This is the most widely used tool for code coverage and analysis.

Install and  Configure Sonarqube on Linux

This guide will help you to setup and configure sonarqube on Linux servers (Redhat/Centos 7 versions) on any cloud platforms like ec2, azure, compute engine or on-premise data centers. Follow the steps given below for the complete sonarqube configuration.

Note: This setup was tested on a Linux ec2  server.

Setup Sonarqube MYSQL Database

1. Install wget

2. Add mysql repositor, install and update it.

3. Install MySQL server.

4. Start MySQL service.

5. Set password for yout MYSQl instance using the following command. The command will prompt for current root password, you can hit enter as there is no default password. All the other prompts are self-explanatory.

6. Login using MySQL client and check the MySQL engine using the following commands. The storage engine should be InnoDB.

7. Create a sonarqube user and a database from MySQL CLI.

8. Grant all privileges on sonarqube database to the sonarqube user.

9. Open /etc/my.cnf file and under [mysqld] section add the query cache parameter. The minimum size should be 15 MB. You can increase the size based on your server type.

READ  List of the best programming languages to learn in 2017

Setup Sonarcube Web Server

1. Download the latest sonarqube installation file to /opt folder. You can get the latest download link from here. http://www.sonarqube.org/downloads/

2. Install unzip and java.

3. Unzip sonarqube source files and rename the folder.

4. Open /opt/sonarqube/conf/sonar.properties, uncomment and edit the parameters as shown below. Change the password accordingly.

By default, sonar will run on 9000. If you want on port 80 or any other port,change the following parameters for accessing the web console on that specific port.

If you want to access sonarqube some path like http://url:/sonar, change the following parameter.

Start Sonarqube Service

To start sonar service, you need to use the script in sonarqube bin directory.

1. Navigate to the start script directory.

2. Start the sonarqube service.

3.Check the application status. If it is in running state, you can access the sonarqube dashboard using the DNS name or Ip address of your server.

Setting up Sonarcube as a service

1. Create a file /etc/init.d/sonar and copy the following content on to the file.

READ  How to Install and Configure Jenkins 2 on centos/Redhat Servers

2. Now, create a symbolic link for /usr/bin/sonar with out sonarqube start scripts in the source file directory. i.e /opt/sonarqube/bin/linux-x86-64

3. Change the file permissions and add sonar to the boot.

4. Once you are done with all the above configurations, you can manage sonar using the following commands.

For sonarqube support, visit this link

In this tutorial, we covered how to install and configure sonarqube on a Linux server. If you face any issues during the setup, please feel free to contact us or leave a comment below.

Free DevOps Resources

Get DevOps news, tutorials and resources in your inbox. A perfect way If you want to get started with devops. Like you, we dont like spam.

4 comments

Leave a Reply

Your email address will not be published. Required fields are marked *