Steps - works for Ubuntu 18.04 but also should work for newer Ubuntu Versions:
Initial SonarQube Installation:
/opt/sonarqube
.Java Version Correction:
Elasticsearch Root Issue:
root
user.User Configuration for SonarQube:
sonar
.sonar
user and group.sonar
user and group.Starting SonarQube:
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.
Initial SonarQube Installation:
Assuming you've downloaded and extracted SonarQube:
wget <SonarQube download link>
tar -xzvf <SonarQube archive>
mv <SonarQube extracted folder> /opt/sonarqube
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.
Elasticsearch Root Issue:
Elasticsearch should not be run as root
. This means SonarQube shouldn't be run as root
either.
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 [Unit] Description=SonarQube service After=syslog.target network.target
[Service] 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
```
Reload systemd:
bash
sudo systemctl daemon-reload
Starting SonarQube:
sudo systemctl start sonar.service
Access Sonar:
The server will available at localhost, port 9000.
The user/password for the first login admin/admin
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-10-21 19:36:21 +0000
Seen: 7 times
Last updated: Oct 21