How to Install and Set Up SonarQube on Windows, Mac, and Linux: Step-by-Step Guide


SonarQube installation

SonarQube is an open-source platform for continuous inspection of code quality to perform automatic reviews with static analysis of code to detect bugs, code smells, and security vulnerabilities. This guide will help you set up SonarQube on your local system.



Before installing SonarQube, ensure you have the following:

  • Java Development Kit (JDK) 11 or 17: SonarQube requires a compatible version of Java to run.


  1. Download SonarQube: Visit the official SonarQube downloads page and download the Community Edition ZIP file.
  2. Extract SonarQube: Unzip the downloaded file to a directory of your choice (e.g., `C:\sonarqube` or `/opt/sonarqube`).


SonarQube includes a built-in web server and a search server. For a local setup, you can use the provided startup scripts.

  1. Navigate to the Bin Directory: Open a terminal or command prompt and navigate to the `bin` directory corresponding to your operating system inside the SonarQube installation folder. For example, on a 64-bit Windows system, this would be `sonarqube-x.x/bin/windows-x86-64`.
  2. Start the Server:

    On Windows:

    StartSonar.bat

    On Mac/Linux:

    ./sonar.sh start
  3. Access SonarQube: Once the server has started (it may take a few moments), open your web browser and go to `http://localhost:9000`.


  1. Log In: The default administrator credentials are:
    • Username: admin
    • Password: admin
  2. Change Password: You will be prompted to change the administrator password upon your first login.


Congratulations! You have successfully installed and set up SonarQube on your system. You can now start creating projects and analyzing your code for quality and security issues.


FAQ


Q: Is the built-in database suitable for production?
A: No, the embedded H2 database is for evaluation purposes only. For production use, you should configure SonarQube to use a supported external database like PostgreSQL, Oracle, or Microsoft SQL Server.


Q: How do I stop the SonarQube server?
A: On Windows, you can press `Ctrl+C` in the console. On Mac/Linux, run `./sonar.sh stop` from the same `bin` directory.


Read Next


Subscribe to Our Newsletter

Get the latest updates and exclusive content delivered to your inbox!