Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 37 Next »

Full installation in 5 steps

Step 1 - Create database

Apache Derby is embedded by default with Sonar. It does not need any installation. It's great for demos and tests but we advice you to use a robust database for real use. The following are currently supported : MySQL 5.x, Oracle 10g XE and Postgresql. It may work on other versions.

We recommend to create an UTF-8 database named 'sonar' accessed by a specific user 'sonar'. Here is an example with MySQL :

Tables and indexes are automatically created when browsing the first time to the homepage (see step 3).

Enabling remote access to MySQL


By default, remote access to MySQL database server is disabled for security reasons. If you want to remotly access to the database server from the Sonar Maven plugin, you need to follow this quick guide.

Step 2 - Install server

Download and unzip the distribution.

Step 3 - Configure database

If you do not use the default embedded database, edit conf/ to configure the database access. Templates are available for MySQL and Oracle. Just uncomment them and comment the first four lines dedicated to derby.
* sonar.jdbc.url : the URL of the database
* sonar.jdbc.driver : the class of the driver
* sonar.jdbc.user : the username (default is 'sonar')
* sonar.jdbc.password : the password (default is 'sonar')

Example for MySQL :

For commercial databases, copy the JDBC driver to /extensions/jdbc-driver/[YOUR DATABASE]/. MySql driver is already provided.

Step 4 - Start server

Mode 1 - Start the standalone application

The default listen port is 9000, the default context path is / and Sonar listens by default to all network interfaces : ''.  Once launched, the Sonar web server is available on http://localhost:9000. Parameters can be changed into the file conf/ Here is an example to listen to http://localhost:80/sonar :

Execute the following script to start the server :

  • on linux/mac : bin/[YOUR PLATEFORM]/ start
  • on windows : bin/windows-x86-32/StartSonar.bat

Note that you can also run as a NT service with bin/windows-x86-32/InstallNTService.bat then bin/windows-x86-32/StartNTService.bat

You can now browse to http://localhost:9000.



Prior to Sonar 1.9, it was necessary to follow setup instructions. From 1.9 setup is run automatically on a fresh installation when launching the server.

Mode 2 - Deploy on application server

See below, the section Deploy on Application Server

Step 5 - Configure Maven2

Sonar uses a Maven2 plugin to analyze sources and to inject measures into the database. That's why database properties must be defined into the Maven2 configuration. Edit settings.xml file, located into $MAVEN_HOME/conf or ~/.m2, and add the parameters from step 3.

If data collection and server are on different boxes, set the server host with the property ''.

Example :

We recommend to increase the Java heap memory. It avoids getting OutOfMemoryError failures. Set the MAVEN_OPTS environment variable :

Run as a service

MS Windows

Install/uninstall NT service :

Start/stop the service :


The following has been tested on Ubuntu 8.10.

Create the file /etc/init.d/sonar with this content :

Register Sonar at boot time :

Declare the Sonar Maven Repository inside Nexus

The Sonar Maven plugin has multiple runtime dependencies on for instance jdbc driver to use, checkstyle or pmd extensions, etc ... To keep Sonar installation simple and avoid Sonar users to manually deploy all those dependencies on their own Maven repository, Sonar server embeds its own repository. This repository can be reached at the following URL : http://yoursonar:sonarport/deploy/maven/README.txt. By default, you don't have to change anything and the Sonar Maven plugin uses the "" property to know where is located this repository.

If  a Maven mirror is defined in your company like the following one :

and you don't want to change this configuration to exclude Sonar Maven Repository from this mirroring mechanism, here is the way you need to configure your Nexus repository manager to declare the Sonar Maven Repository :

1- Add a new repository with the following properties :

2- Add this newly created repository to your public group of repositories.

3- No more to do except launching the Sonar Maven plugin on a project to check your new configuration.



The status of this repository inside Nexus will remain "In Service - Checking remote ...". This is due to a limitation (SONAR-603), which should be fixed in the next version of Sonar.

Running Sonar behind an Apache Proxy

This section helps you configure Sonar if you want to run Sonar behind a proxy. This can be done for security concerns or to consolidate multiple disparate applications. We assume that you've already installed Apache 2 with module mod_proxy, that you are using a Virtual Host for and that Sonar is running and available on http://sonahost:sonarport/.

At this point, edit the HTTPd configuration file for the virtual host. Include the following to expose Sonar via mod_proxy at :

By default, mod_proxy uses HTTP protocol to communicate with the Sonar instance. For performance concerns, you might prefer using the AJP13 protocol. This protocol is packet-oriented. A binary format is chosen over the more readable plain text for reasons of performance. To cut down on the expensive process of socket creation, the web server will attempt to maintain persistent TCP connections to the servlet container, and to reuse a connection for multiple request/response cycles.

If you want to use this AJP13 protocol you must to activate the mod_proxy_ajp module and then edit the configuration file and uncomment the sonar.ajp13.port property :

Once this done, edit the HTTPd configuration file for the virtual host and make the following changes :

Apache configuration is going to vary based on your own application's requirements and the way you intend to expose Sonar to the outside world. If you need more details about Apache HTTPd, mod_proxy and mod_proxy_ajp, please see

Deploy on application server

Sonar can be packaged as a WAR then deployed into an existing J2EE application server. To use this method of installation, you must already know how to deploy a web application on the application server of choice.

Supported servers

The only supported server is Tomcat 5.x.

Potentially compatible servers

The following application servers are not supported but have been tested by users :




Tomcat 6.x



Jonas 4



Glassfish 2



Glassfish 3 Prelude




Steps are :

  • edit conf/ as described in standalone mode. The file conf/wrapper.conf is never used when deploying to application server.
  • execute the script (or build-war.bat on MS Windows) from the directory war/
  • deploy war/sonar.war to the application server
  • browse to http://localhost/sonar and follow setup instructions

    A minimum heap size of 512Mo is required.


    The WAR file must be rebuilt each time the configuration is updated (conf/ or new extensions).

Tomcat notes

To increase memory heap size, set the CATALINA_OPTS variable before starting Tomcat :

Jonas 4 notes

Edit conf/ and uncomment the following property :

Glassfish 3 Prelude notes

 To increase memory heap size, browse to the administration console (http://localhost:4848 by default) and go to Application server -> JVM Settings -> JVM Options. Add the properties :

  • No labels