Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Steps - works for Ubuntu 18.04 but also should work for newer Ubuntu Versions:

  1. Initial SonarQube Installation:

    • Downloaded and extracted SonarQube to /opt/sonarqube.
  2. Java Version Correction:

    • SonarQube failed to start due to a Java version mismatch.
    • Installed Java 17 since SonarQube expected it (class file version 61.0 relates to Java 17).
    • Set Java 17 as the default version.
  3. Elasticsearch Root Issue:

    • Elasticsearch, a component of SonarQube, was failing to start because it cannot run as the root user.
  4. User Configuration for SonarQube:

    • Created a dedicated system user named sonar.
    • Changed ownership of the SonarQube installation directory to the sonar user and group.
    • Modified the SonarQube systemd service file to run the service as the sonar user and group.
    • Reloaded systemd to apply the changes to the service file.
  5. Starting SonarQube:

    • Successfully started SonarQube using systemctl start sonar.service.

By addressing the Java version discrepancy and ensuring that Elasticsearch does not run as the root user, SonarQube was able to start up and operate correctly on the system.


  1. Initial SonarQube Installation:

    Assuming you've downloaded and extracted SonarQube:

    wget <SonarQube download link>
    tar -xzvf <SonarQube archive>
    mv <SonarQube extracted folder> /opt/sonarqube
    
  2. Java Version Correction:

    SonarQube requires Java 17. You installed it and set it as default:

    sudo apt install openjdk-17-jdk
    sudo update-alternatives --config java
    

    You chose Java 17 from the list to set it as default.

  3. Elasticsearch Root Issue:

    Elasticsearch should not be run as root. This means SonarQube shouldn't be run as root either.

  4. User Configuration for SonarQube:

    • Create a dedicated system user named sonar:

      sudo adduser --system --no-create-home --group sonar
      
    • Change ownership of the SonarQube directory:

      sudo chown -R sonar:sonar /opt/sonarqube
      
    • Modify the SonarQube systemd service file:

      Open the file:

      sudo nano /etc/systemd/system/sonar.service
      

      Add/modify the User and Group directives: ``` [Service] User=sonar Group=sonar

      [Unit] Description=SonarQube service After=syslog.target network.target

      [Service] Type=simple User=sonar Group=sonar ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh console ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop Restart=always

    [Install] WantedBy=multi-user.target ```

    • Reload systemd:

      sudo systemctl daemon-reload
      
  5. Starting SonarQube:

    sudo systemctl start sonar.service
    

With these adjustments, SonarQube should be running correctly on your Ubuntu 22.04 machine. Remember, many of these steps are crucial not just for functionality but also for maintaining a secure deployment of SonarQube and Elasticsearch. Always avoid running services as root unless absolutely necessary.

Steps - works for Ubuntu 18.04 but also should work for newer Ubuntu Versions:

  1. Initial SonarQube Installation:

    • Downloaded and extracted SonarQube to /opt/sonarqube.
  2. Java Version Correction:

    • SonarQube failed to start due to a Java version mismatch.
    • Installed Java 17 since SonarQube expected it (class file version 61.0 relates to Java 17).
    • Set Java 17 as the default version.
  3. Elasticsearch Root Issue:

    • Elasticsearch, a component of SonarQube, was failing to start because it cannot run as the root user.
  4. User Configuration for SonarQube:

    • Created a dedicated system user named sonar.
    • Changed ownership of the SonarQube installation directory to the sonar user and group.
    • Modified the SonarQube systemd service file to run the service as the sonar user and group.
    • Reloaded systemd to apply the changes to the service file.
  5. Starting SonarQube:

    • Successfully started SonarQube using systemctl start sonar.service.

By addressing the Java version discrepancy and ensuring that Elasticsearch does not run as the root user, SonarQube was able to start up and operate correctly on the system.


  1. Initial SonarQube Installation:

    Assuming you've downloaded and extracted SonarQube:

    wget <SonarQube download link>
    tar -xzvf <SonarQube archive>
    mv <SonarQube extracted folder> /opt/sonarqube
    
  2. Java Version Correction:

    SonarQube requires Java 17. You installed it and set it as default:

    sudo apt install openjdk-17-jdk
    sudo update-alternatives --config java
    

    You chose Java 17 from the list to set it as default.

  3. Elasticsearch Root Issue:

    Elasticsearch should not be run as root. This means SonarQube shouldn't be run as root either.

  4. User Configuration for SonarQube:

    • Create a dedicated system user named sonar:

      sudo adduser --system --no-create-home --group sonar
      
    • Change ownership of the SonarQube directory:

      sudo chown -R sonar:sonar /opt/sonarqube
      
    • Modify the SonarQube systemd service file:

      Open the file:

      sudo nano /etc/systemd/system/sonar.service
      

      Add/modify the User and Group directives: ``` directives:

      ```bash [Service] User=sonar Group=sonar

      [Unit] Description=SonarQube service After=syslog.target network.target

      [Service] Type=simple User=sonar Group=sonar ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh console ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop Restart=always

    [Install] WantedBy=multi-user.target ```

    • Reload systemd:

      sudo systemctl daemon-reload
      
  5. Starting SonarQube:

    sudo systemctl start sonar.service
    

With these adjustments, SonarQube should be running correctly on your Ubuntu 22.04 machine. Remember, many of these steps are crucial not just for functionality but also for maintaining a secure deployment of SonarQube and Elasticsearch. Always avoid running services as root unless absolutely necessary.

Steps - works for Ubuntu 18.04 but also should work for newer Ubuntu Versions:

  1. Initial SonarQube Installation:

    • Downloaded and extracted SonarQube to /opt/sonarqube.
  2. Java Version Correction:

    • SonarQube failed to start due to a Java version mismatch.
    • Installed Java 17 since SonarQube expected it (class file version 61.0 relates to Java 17).
    • Set Java 17 as the default version.
  3. Elasticsearch Root Issue:

    • Elasticsearch, a component of SonarQube, was failing to start because it cannot run as the root user.
  4. User Configuration for SonarQube:

    • Created a dedicated system user named sonar.
    • Changed ownership of the SonarQube installation directory to the sonar user and group.
    • Modified the SonarQube systemd service file to run the service as the sonar user and group.
    • Reloaded systemd to apply the changes to the service file.
  5. Starting SonarQube:

    • Successfully started SonarQube using systemctl start sonar.service.

By addressing the Java version discrepancy and ensuring that Elasticsearch does not run as the root user, SonarQube was able to start up and operate correctly on the system.


  1. Initial SonarQube Installation:

    Assuming you've downloaded and extracted SonarQube:

    wget <SonarQube download link>
    tar -xzvf <SonarQube archive>
    mv <SonarQube extracted folder> /opt/sonarqube
    
  2. Java Version Correction:

    SonarQube requires Java 17. You installed it and set it as default:

    sudo apt install openjdk-17-jdk
    sudo update-alternatives --config java
    

    You chose Java 17 from the list to set it as default.

  3. Elasticsearch Root Issue:

    Elasticsearch should not be run as root. This means SonarQube shouldn't be run as root either.

  4. User Configuration for SonarQube:

    • Create a dedicated system user named sonar:

      sudo adduser --system --no-create-home --group sonar
      
    • Change ownership of the SonarQube directory:

      sudo chown -R sonar:sonar /opt/sonarqube
      
    • Modify the SonarQube systemd service file:

      Open the file:

      sudo nano /etc/systemd/system/sonar.service
      

      Add/modify the User and Group directives:

      ```bash [Service] User=sonar Group=sonar

      [Unit] Description=SonarQube service After=syslog.target network.target

      [Service] Type=simple User=sonar Group=sonar ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh console ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop Restart=always

    [Install] WantedBy=multi-user.target ```

    • Reload systemd:

      sudo systemctl daemon-reload
      
  5. Starting SonarQube:

    sudo systemctl start sonar.service
    
  6. Access Sonar:

With these adjustments, SonarQube should be running correctly on your Ubuntu 22.04 machine. Remember, many of these steps are crucial not just The server will available at localhost, port 9000.

The user/password for functionality but also for maintaining a secure deployment of SonarQube and Elasticsearch. Always avoid running services as root unless absolutely necessary.

the first login admin/admin

Steps - works for Ubuntu 18.04 but also should work for newer Ubuntu Versions:

  1. Initial SonarQube Installation:

    • Downloaded and extracted SonarQube to /opt/sonarqube.
  2. Java Version Correction:

    • SonarQube failed to start due to a Java version mismatch.
    • Installed Java 17 since SonarQube expected it (class file version 61.0 relates to Java 17).
    • Set Java 17 as the default version.
  3. Elasticsearch Root Issue:

    • Elasticsearch, a component of SonarQube, was failing to start because it cannot run as the root user.
  4. User Configuration for SonarQube:

    • Created a dedicated system user named sonar.
    • Changed ownership of the SonarQube installation directory to the sonar user and group.
    • Modified the SonarQube systemd service file to run the service as the sonar user and group.
    • Reloaded systemd to apply the changes to the service file.
  5. Starting SonarQube:

    • Successfully started SonarQube using systemctl start sonar.service.

By addressing the Java version discrepancy and ensuring that Elasticsearch does not run as the root user, SonarQube was able to start up and operate correctly on the system.


  1. Initial SonarQube Installation:

    Assuming you've downloaded and extracted SonarQube:

    wget <SonarQube download link>
    tar -xzvf <SonarQube archive>
    mv <SonarQube extracted folder> /opt/sonarqube
    
  2. Java Version Correction:

    SonarQube requires Java 17. You installed it and set it as default:

    sudo apt install openjdk-17-jdk
    sudo update-alternatives --config java
    

    You chose Java 17 from the list to set it as default.

  3. Elasticsearch Root Issue:

    Elasticsearch should not be run as root. This means SonarQube shouldn't be run as root either.

  4. User Configuration for SonarQube:

    • Create a dedicated system user named sonar:

      sudo adduser --system --no-create-home --group sonar
      
    • Change ownership of the SonarQube directory:

      sudo chown -R sonar:sonar /opt/sonarqube
      
    • Modify the SonarQube systemd service file:

      Open the file:

      sudo nano /etc/systemd/system/sonar.service
      

      Add/modify the User and Group directives:

      ```bash [Service] User=sonar Group=sonar

      [Unit] [Unit] Description=SonarQube service After=syslog.target network.target

[Service] Type=simple Type=simple User=sonar Group=sonar LimitNOFILE=65536 ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh console ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop Restart=always

[Install] WantedBy=multi-user.target WantedBy=multi-user.target
```

  • Reload systemd:

    bash sudo systemctl daemon-reload

  1. Starting SonarQube:

    sudo systemctl start sonar.service
    
  2. Access Sonar:

The server will available at localhost, port 9000.

The user/password for the first login admin/admin