Sonar Qube & Scanner Installation For Php
Before running the below commands to install and run SonarQube using Docker, make sure that you have Docker installed on your Linux system and that you have enough free memory (at least 1.5 GB).
To check if Docker is installed on your system, you can run the following command:
docker --version
If Docker is installed, this command will print the version number. If Docker is not installed, you will need to install it before you can proceed with the SonarQube installation.
To check the available memory on your system, you can use the free
command:
free -m
This will print the total, used, and available memory in megabytes. Make sure that the available memory is at least 1.5 GB before proceeding with the SonarQube installation.

To install and run SonarQube using Docker, follow these steps:
- Pull the SonarQube image from Docker Hub using the
docker pull
command:docker pull sonarqube
- Run the SonarQube container using the
docker run
command. Use the-dit
flag to run the container in detached mode and the-p
flag to specify the port mapping. Use the-name
flag to give the container a name, and specify the image name and tag (in this case,sonarqube:latest
):docker run -dit -p 9000:9000 - name sonarqube sonarqube:latest
3. This will start the SonarQube container and expose it on port 9000. You can then access the SonarQube web interface by visiting http://localhost:9000
in a web browser.

To install the SonarQube Scanner for PHP, follow these steps:
- Download the SonarQube Scanner for PHP using
wget
:wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.7.0.2747-linux.zip
- Unzip the downloaded file using
unzip
:unzip sonar-scanner-cli-4.7.0.2747-linux.zip
- Change the current directory to the
bin
directory of the unzipped folder:cd sonar-scanner-4.7.0.2747-linux/bin
- Export the
bin
directory to thePATH
environment variable:export PATH=$PATH:/root/group-service/sonar-scanner-4.7.0.2747-linux/bin
Note: Make sure to replace /root/group-service/
with the actual path to the sonar-scanner-4.7.0.2747-linux
directory on your system.
This should install the SonarQube Scanner for PHP on your system. You can then use the sonar-scanner
command to run a SonarQube analysis on your PHP code.