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, SQL Server 2005. 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).
Step 2 - Install server
Download and unzip the distribution.
Step 3 - Configure database
If you do not use the default embedded database, edit conf/sonar.properties 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 and jTDS for SqlServer drivers are already provided.
Step 4 - Start server
Mode 1 - Start the standalone application
The default listen port is 9000 and the context path is /, so the web server listens to http://localhost:9000. Parameters can be changed into the file conf/sonar.properties. 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]/sonar.sh 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 and follow setup instructions.
Mode 2 - Deploy on application server
More details on the page 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 four parameters from step 2.
If data collection and server are on different boxes, set the server host with the property 'sonar.host.url'.
We recommend to increase the Java heap memory. It avoids getting OutOfMemoryError failures. Set the MAVEN_OPTS environment variable :
Run as a service
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 :
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.
The only supported server is Tomcat 5.x.
Potentially compatible servers
The following application servers are not supported but have been tested by users :
Glassfish 3 Prelude
Steps are :
- edit conf/sonar.properties as described in standalone mode. The file conf/wrapper.conf is never used when deploying to application server.
- execute the script build-war.sh (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
To increase memory heap size, set the CATALINA_OPTS variable before starting Tomcat :
Jonas 4 notes
Edit conf/sonar.properties 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 :