Bonjour,
Voici comment installer SonarQube 10.4
Installer OpenJDK :
CentOS / Fedora / RHEL
yum install -y java-17-openjdk nginx unzip wget postgresql-server postgresql-contrib
Debian / Ubuntu
apt-get install -y openjdk-17-jdk nginx unzip wget postgresql postgresql-contrib
Configurer PostgreSQL :
systemctl enable --now postgresql
postgresql-setup initdb
su - postgres
psql
CREATE USER sonarqube WITH ENCRYPTED PASSWORD 'my_password';
CREATE DATABASE sonarqube OWNER sonarqube;
GRANT ALL PRIVILEGES ON DATABASE sonarqube TO sonarqube;
\q
exit
Télécharger SonarQube :
mkdir -p /opt/sonarqube /root/.ssl
wget -O /opt/sonarqube/sonarqube.zip https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-10.4.0.87286.zip
cd /opt/sonarqube && unzip -D sonarqube.zip
mv /opt/sonarqube/sonarqube-* /opt/sonarqube/
rm -f /opt/sonarqube/sonarqube.zip
rmdir sonarqube-*
Créer un utilisateur dédié :
groupadd -r sonarqube
useradd -r -g sonarqube -d /opt/sonarqube -s /sbin/nologin sonarqube
chown -R sonarqube: /opt/sonarqube
Configurer SonarQube :
nano /opt/sonarqube/conf/sonar.properties
sonar.web.host=0.0.0.0
sonar.web.port=9000
sonar.jdbc.username=sonarqube
sonar.jdbc.password=My_Password
sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube
sonar.web.javaOpts=-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError
sonar.search.javaOpts=-Xmx512m -Xms512m -XX:MaxDirectMemorySize=256m -XX:+HeapDumpOnOutOfMemoryError
sonar.path.data=data
sonar.path.temp=temp
sonar.telemetry.enable=false
echo "vm.max_map_count=262144" >> /etc/sysctl.conf
echo "fs.file-max=65536" >> /etc/sysctl.conf
sysctl --system
Créer le service :
nano /etc/systemd/system/sonarqube.service
[Unit]
Description=SonarQube 10
After=network.target
After=postgresql.service
[Service]
Type=forking
WorkingDirectory=/opt/sonarqube/bin
User=sonarqube
Group=sonarqube
LimitNOFILE=65536
LimitNPROC=4096
ExecStart=/opt/sonarqube/bin/linux-x86-64/sonar.sh start
ExecStop=/opt/sonarqube/bin/linux-x86-64/sonar.sh stop
Restart=on-failure
[Install]
WantedBy=multi-user.target
Démarrer SonarQube :
systemctl enable --now sonarqube
Check Logs :
tail /opt/sonarqube/logs/nohup.log
tail /opt/sonarqube/logs/sonar.log
Configurer Nginx :
nano /etc/nginx/conf.d/sonarqube.conf
Exemple :
server {
listen 80 default_server;
server_name sonar.my_domain.com;
access_log /var/log/nginx/sonarqube-access.log;
error_log /var/log/nginx/sonarqube-error.log error;
## The default `client_max_body_size` is 1M, this might not be enough for some posters, etc.
client_max_body_size 200M;
# See https://hstspreload.org/ before uncommenting the line below.
# add_header Strict-Transport-Security "max-age=15768000; preload;";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header Content-Security-Policy "frame-ancestors 'self'";
add_header X-Frame-Options DENY;
add_header Referrer-Policy same-origin;
location / {
proxy_pass http://localhost:9000;
proxy_set_header Host $host;
proxy_buffering off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_set_header X-Forwarded-Host $http_host;
}
}
systemctl reload nginx
User : admin
Pwd : admin