How to install SonarQube on Ubuntu 16.0.4? Install Sonarqube on Ubuntu
SonarQube is one of the popular static code analysis tool. SonarQube is java based tool along with back end - back end can be MySQL, Oracle or PostgreSQL. We will use Postgres for set up on Ubuntu.
Please find steps for installing SonarQube on Ubuntu EC2. Make sure port 9000 is opened in security group(firewall rule).
Let us start with java install (skip java install if you already have it installed)
Install Open JDK 11
sudo apt-get update && sudo apt-get install default-jdk -y
Postgres Installation
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/
sudo apt-get -y install postgresql postgresql-contrib
Ignore the message in red color below:
sudo systemctl start postgresql
sudo systemctl enable postgresql
Login as postgres user
sudo su - postgres
Now create a user below by executing below command
sudo su - postgres
3. Download SonarQube and Install
sudo apt-get -y install unzip
sudo unzip sonarqube*.zip -d /opt
sudo mv /opt/sonarqube-8.6.0.39681 /opt/sonarqube -v
Create Group and User:
sudo groupadd sonarGroup
Now add the user with directory access
sudo useradd -c "user to run SonarQube" -d /opt/sonarqube -g sonarGroup sonar
sudo chown sonar:sonarGroup /opt/sonarqube -R
sudo vi /opt/sonarqube/conf/sonar.prop
uncomment the below lines by removing # and add values highlighted yellow
sonar.jdbc.username=sonar
sonar.jdbc.password=password
sonar.jdbc.url=jdbc:postgresql
Press escape, and enter :wq! to come out of the above screen.
Edit the sonar script file and set RUN_AS_USER
sudo vi /opt/sonarqube/bin/linux-x86-64/sonar.sh
Add enable the below line
RUN_AS_USER=sonar
Create Sonar as a service(this will enable to start automatically when you restart the server)
Execute the below command:
sudo vi /etc/systemd/system/sonar.serv
add the below code in green color:
[Unit]
Description=SonarQube service
After=syslog.target network.target
[Service]
Type=forking
ExecStart=/opt/sonarqube/bin/l
ExecStop=/opt/sonarqube/bin/li
LimitNOFILE=131072
LimitNPROC=8192
User=sonar
Group=sonarGroup
Restart=always
[Install]
WantedBy=multi-user.target
Save the file by entering :wq!
Kernel System changes
we must make a few modifications to a couple of kernel system limits files for sonarqube to work.
sudo vi /etc/sysctl.conf
Add the following lines to the bottom of that file:
vm.max_map_count=262144
fs.file-max=65536
Next, we're going to edit limits.conf. Open that file with the command:
sudo vi /etc/security/limits.conf
At the end of this file, add the following:
At the end of this file, add the following:
sonar - nofile 65536
sonar - nproc 4096
Reload system level changes without server boot
sudo sysctl -p
Start SonarQube Now
sudo systemctl start sonar
Now access sonarQube UI by going to browser and enter public dns name with port 9000
Now to go to browser --> http://your_SonarQube_publicdns_name:9000 /
Click here to learn how to integrate SonarQube with Jenkins.
The default username : admin and password=admin
No comments:
Post a Comment