Sonar is made of 3 components:
- A Database that stores the configuration and results of quality analysis
- A Web Server that is used to navigate the results of the analyzes and make configuration
- A Client that will run source code analyzers to compute data on projects
Sonar supports several database engines you can choose amongst.
If you simply want to make a test or a demo, you can use H2 (Apache Derby prior to Sonar 3.2) as a database. H2 (Derby prior to Sonar 3.2) is shipped with Sonar and does not need any installation. This database must not be used for production.
To use one of the other databases, you simply need to create a schema and provide permissions to create, update and delete objects. Tables and indexes will then be automatically created when launching Sonar for the first time. A sample scripts to create the schema in MySQL can be found in here.
When creating a database, the recommended character set is UTF-8.
Installing Sonar Server
- Prior to the installation, check the requirements.
- Download and unzip the distribution (note that native packages are also available for Linux distributions, see this documentation page for more details).
If you do not use the default embedded database, edit conf/sonar.properties to configure the database access. Templates are available for every supported database. Just uncomment them and comment the lines dedicated to H2 (Derby prior to version 3.2):
- sonar.jdbc.url: the URL of the database
- sonar.jdbc.driver: the class of the driver
- sonar.jdbc.user: the username
- sonar.jdbc.password: the password
For Oracle, copy the JDBC driver to /extensions/jdbc-driver/[YOUR DATABASE]/.
Other drivers for supported database are already provided (do not replace provided drivers as they are the only ones supported).
Starting Sonar Server
The default listen port is 9000, the default context path is / and Sonar listens by default to all network interfaces: '0.0.0.0'. Once launched, the Sonar web server is available on http://localhost:9000. Parameters can be changed into the file conf/sonar.properties:
sonar.web.host : 192.0.0.1 sonar.web.port: 80 sonar.web.context: /sonar
Execute the following script to start the server:
- On Linux/Mac OS: bin/<YOUR OS>/sonar.sh start
- On Windows: bin/windows-x86-32/StartSonar.bat
- Read Installing on AIX, HPUX or Solaris for other platforms
You can now browse to http://localhost:9000.
Advanced Installation Features
- Deploying Sonar on a Tomcat or Jetty
- Running Sonar as a Service on Windows or Linux
- Running Sonar behind a Proxy
There are different kinds of client to launch analysis:
- Sonar Runner: recommended as the default one, see installation and configuration guide.
- Maven: recommended for projects built with Maven, see installation and configuration guide.
- Ant Task: recommended for projects built with Ant, see installation and configuration guide.
- CI Engine: see Hudson/Jenkins plugin or Bamboo plugin or AnthillPro plugin. Note that other CI engines can be used even if there is no Sonar plugin available.