DEV Community

KALPESH
KALPESH

Posted on

SonarQube Installation on EC2

Install SonarQube in the /opt directory on Ubuntu, follow these steps:

  1. Update Package List and Install Dependencies:

    sudo apt update -y
    sudo apt install openjdk-11-jdk wget unzip
    
  2. Download SonarQube: Visit the SonarQube download page to get the latest version URL or use the command below for a specific version. For example:

    wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.6.1.62043.zip
    
  3. Extract the Downloaded File:

    sudo unzip sonarqube-9.6.1.62043.zip -d /opt
    
  4. Create a SonarQube User (Optional but recommended for security):

    sudo useradd --system --home /opt/sonarqube --shell /bin/false sonarqube
    
  5. Change Ownership of the SonarQube Directory:

    sudo chown -R sonarqube:sonarqube /opt/sonarqube-9.6.1.62043
    
  6. Configure SonarQube: Edit the sonar.properties file to set up SonarQube (e.g., database configuration, web server ports, user & passwd):

    sudo vi /opt/sonarqube-9.6.1.62043/conf/sonar.properties
    
  7. Create a Systemd Service File: Create a service file for SonarQube to manage it as a systemd service:

    sudo vi /etc/systemd/system/sonarqube.service
    

    Add the following content:

    [Unit]
    Description=SonarQube
    After=syslog.target network.target
    
    [Service]
    Type=forking
    User=sonarqube
    Group=sonarqube
    ExecStart=/opt/sonarqube-9.6.1.62043/bin/linux-x86-64/sonar.sh start
    ExecStop=/opt/sonarqube-9.6.1.62043/bin/linux-x86-64/sonar.sh stop
    LimitNOFILE=65536
    LimitNPROC=8192
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
    
  8. Reload Systemd and Start SonarQube:

    bashCopy codesudo systemctl daemon-reload
    sudo systemctl start sonarqube
    sudo systemctl enable sonarqube
    
  9. Access SonarQube at http://<public IP>:9000

Feel free to share and spread the knowledge! 🌟😊 Enjoy Learning! 😊

Top comments (0)