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 88 Next »

Installation in 4 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.1.x, Oracle 10g XE, PostgreSQL and MS SqlServer 2005. It may work on other versions.

To use one of the external database, it is necessary to explicitly set up the initial database schema and permissions. Tables and indexes will then be automatically created when launching Sonar for the first time. Example scripts for setting MySQL up can be found in extras/database/mysql

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 every supported database. 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 value is 'sonar')
  • sonar.jdbc.password : the password (default value is 'sonar')

Example for MySQL :

For Oracle, copy the JDBC driver to /extensions/jdbc-driver/[YOUR DATABASE]/. Other drivers for supported database are 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 : '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. Here is an example to listen to http://localhost:80/sonar :


Execute the following script to start the server :

  • On Linux/Mac OS : bin/<YOUR OS>/sonar.sh start
  • On MS Windows : bin/windows-x86-32/StartSonar.bat
  • Read "Install on AIX, HPUX or Solaris" for other platforms

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.

Mode 2 - Deploy on JEE Server

Sonar can be packaged as a WAR then deployed into an existing JEE server. To use this method of installation, you must already know how to deploy a web application on the application server of choice. The supported servers are Tomcat 5.x, 6.x, 7.x and Jetty 6.x.

Installation 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
Icon

A minimum heap size of 512Mb is required. To increase memory heap size on Tomcat, set the CATALINA_OPTS variable before starting Tomcat

Prior to Sonar 2.2, the WAR file must be rebuilt each time the configuration is updated (new plugins or new extensions).
From Sonar 2.2 onwards, the WAR file is now linked to the Sonar directory (the directory where the distribution is unzipped). It implies that :

  • the directory where the distribution is unzipped cannot be removed
  • there is no need to rebuild the WAR when installing/uninstalling plugins or rule extensions
  • the WAR file must be deployed on the host which contains the Sonar directory
  • the WAR file must be rebuilt when the Sonar directory is moved
  • the WAR file must be rebuilt when a configuration file is updated (directory conf/)
    Icon

    The user who runs Tomcat must have read & write access to Sonar home directory (to allow plugin install from the Web admin console for instance).

More details on this blog.

Mode 3 - Run as a service on MS Windows

Install/uninstall NT service :

Start/stop the service :


Mode 4 - Run as a service on Linux

The following has been tested on Ubuntu 8.10.

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

Register Sonar at boot time :

Running Sonar behind a 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.

Running Sonar behind an Apache Proxy

We assume that you've already installed Apache 2 with module mod_proxy, that you are using a Virtual Host for www.somecompany.com and that Sonar is running and available on http://sonahost:sonarport/.

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

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 sonar.properties configuration file and uncomment the sonar.ajp13.port property :

Once this done, edit the HTTPd configuration file for the www.somecompany.com 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 http://httpd.apache.org.

Running Sonar behind Nginx

We assume that you've already installed Nginx, that you are using a Virtual Host for www.somecompany.com and that Sonar is running and available on http://sonahost:sonarport/.

At this point, edit the Nginx configuration file. Include the following to expose Sonar at http://www.somecompany.com/ :

Nginx 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 Nginx, please see http://nginx.org.

  • No labels