
SonarQube is an open-source web-based platform for code quality analysis based on Java. That is to detect bugs, code smells, and security vulnerabilities. It analyses a wide range of code written in different programming languages, for example, JavaScript, PHP, C#, C/C++, and Java through plugins. It's customizable to test certain aspects of the source code with limits dependent on the expected output. The output is a detailed report that captures all the domains within code quality analysis.
This article guides you on how to install SonarQube on Debian 11.0 server.
Perform the following steps first:
Update the packages.
Install dependencies.
Install Java 11.
Add PostgreSQL repository.
Add the PostgreSQL signing key.
Update the system.
Install PostgreSQL.
Enable PostgreSQL service to start on system boot.
Start PostgreSQL service.
Change postgres default user password.
Log in with user postgres.
Create sonarqube user.
Enter the PostgreSQL interactive shell.
Set password for user sonarqube. Change SecurePassword with your secure password.
Create database named sonarqube.
Grant all the privileges on the sonarqube database to the sonarqube user.
Exit the PostgreSQL shell.
Return to your non-root account.
Download the latest version of SonarQube. To find the latest version, visit the download page.
Extract the downloaded archive.
Create the installation directory /opt/sonarqube.
Move the extracted files into the installation directory.
Create a System User account for SonarQube.
Change the ownership of the installation directory.
Edit the properties file to update the database credential.
The final file should have the following changes. Save and close the file.
Create a systemd service file.
Add the bellow code to the file. Save and close the file.
Edit the sonar script file.
Find this line. To search for it, use Control+W, enter search phrase then press Enter.
Now uncomment the line and change it. Finally, save and exit the file.
Reload the system daemon.
Enable SonarQube service to start on system boot.
Start SonarQube service.
Check the service status.
Allow SonarQube default port 9000 through the system's firewall.
Install and configure Nginx as a reverse proxy for SonarQube. This enables you to access the web interface through port 80 instead of port 9000.
Install Nginx.
Enable Nginx service to start on system boot.
Unlink Nginx default configuration file.
Create a new Nginx configuration file named sonarqube.conf.
Add the following code to the file. Save and close the file.
Enable the new configuration file.
Allow port 80 through the system's firewall.
Test Nginx configuration.
Restart the Nginx service.
Edit the sysctl configuration file to change some system defaults.
Add the below code to the file. Then, save and exit the file.
Reload the sysctl configurations for changes to take effect.
Go to your browser and go to the URL http://Server_IP/. For example:
You have installed SonarQube on Debian 11.0 server. Login with the default credential with your username as admin and your password as admin. You can now continue and begin creating accounts for code analysis.
For more information on SonarQube, please visit the official documentation.
0 Comments
Be the first to comment and share your perspective with the community.