Zul Kawser is a tech professional skilled in PHP (Laravel, Codeigniter), Javascript (Vue.js), AWS, and DevOps. With a focus on crafting efficient web solutions, he brings expertise in both backend and frontend development, making him a valuable asset in the ever-evolving tech landscape.
Make sure Docker is installed on your VM. In this example, Ubuntu 22.04 is used.
Check your Docker version:
docker -v
In this case, the Docker version is 24.0.7
1. Run SonarQube container:
docker run -d --name sonarqube -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p 9001:9000 sonarqube:latest
2. Check the running containers:
docker ps
3. Open your browser and navigate to http://localhost:9001/
Congratulation! You have successfully install
4. Login using the default credentials:
Username: admin
Password: admin
5. Change your password for security:
Explore the SonarQube dashboard with various options:
Here is lots of option.
1. Click on “Create Project” and provide the project name and key.
2. Use global settings and click on “Create Project.”
3. Click on “Locally”
4. Click “Generate” button to generate token.
5. Click on “Continue” button
6. choose “Other” option
1. Install Java:
Make sure Java is installed on your system. You can install OpenJDK or Oracle JDK. Here’s an example command to install OpenJDK on Ubuntu:
sudo apt-get update
sudo apt-get install openjdk-11-jdk
Adjust the version number based on your requirements.
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
Make sure to replace the path with the correct one based on your Java installation.
Then, apply the changes:
source ~/.bashrc
java -version
This should display information about the installed Java version.
echo $JAVA_HOME
Okay! Now we need to install sonar-scanner.
Follow these steps or refer to SonarQube Scanner documentation:
Download Linux 64-bit or you can do by cmd
sudo mkdir /opt/sonar-scanner
sudo wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472.zip -P /opt/sonar-scanner
sudo unzip /opt/sonar-scanner/sonar-scanner-cli-4.6.2.2472.zip -d /opt/sonar-scanner
Okay! Now we need to install sonar-scanner.
Follow these steps or refer to SonarQube Scanner documentation:
Download Linux 64-bit or you can do by cmd
sudo mkdir /opt/sonar-scanner
sudo wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.6.2.2472.zip -P /opt/sonar-scanner
sudo unzip /opt/sonar-scanner/sonar-scanner-cli-4.6.2.2472.zip -d /opt/sonar-scanner
export PATH=$PATH:/opt/sonar-scanner/sonar-scanner-4.6.2.2472/bin
Make sure to adjust the version and path based on your installation.
source ~/.bashrc
chmod +x /etc/sonarqube-scanner/sonar-scanner-4.6.2.2472/bin/sonar-scanner
4. Verify Installation:
sonar-scanner -v
This command should display the version information of the installed SonarQube Scanner.
Now, you have installed the SonarQube Scanner in the /opt/sonar-scanner directory. You can use it to analyze your projects and send the results to a SonarQube server.
Yes! We almost done
Create a configuration file in your project’s root directory called sonar-project.properties
set the sonar.projectKey=demo Replace “demo” with your project key and adjust the token accordingly.
Copy the Execute code
Now go to your project root directory and run. In my case
sonar-scanner \
-Dsonar.projectKey=demo \
-Dsonar.sources=. \
-Dsonar.host.url=http://localhost:9001 \
-Dsonar.token=sqp_e8bd7f10644a91db160c823f30db1fb83b3d9fa3
Copy the Execute Code from the
paste and hit enter
Congratulations! You have successfully installed and configured SonarQube for your Laravel project.
Tags :