Skip to content

Instantly share code, notes, and snippets.

What would you like to do?

Connect to Amazon EC2 Instance

Connecting from Windows:

Connecting from Linux:

Install MySQL

To install MySQL, run the following command from a terminal prompt: sudo apt-get install mysql-server

During the installation process you will be prompted to enter a password for the MySQL root user. username / password : root / root

Once the installation is complete, the MySQL server should be started automatically. You can run the following command from a terminal prompt to check whether the MySQL server is running: sudo netstat -tap | grep mysql

When you run this command, you should see the following line or something similar: tcp 0 0 localhost:mysql *:* LISTEN 2759/mysqld

If the server is not running correctly, you can type the following command to start it: sudo service mysql restart

If you would like to change the MySQL root password, in a terminal enter: sudo dpkg-reconfigure mysql-server-5.5

The MySQL daemon will be stopped, and you will be prompted to enter a new password.

MySQL Configuration

  1. Create an empty schema and a sonarqube user. Grant this sonarqube user permissions to create, update and delete objects for this schema. The charset of the database has to be set to "UTF-8" and the language (database and user) to "English".

    1. create and edit a script file create_database.sql

      CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
      CREATE USER ‘sonar’ IDENTIFIED BY ‘sonar';
      GRANT ALL ON sonar.* TO ‘sonar’@’%’ IDENTIFIED BY ‘sonar';
      GRANT ALL ON sonar.* TO ‘sonar’@’localhost’ IDENTIFIED BY ‘sonar';
    2. To run the script: sudo mysql -u root -p < create_database.sql

    3. To verify the user has been created: SELECT User FROM mysql.user; you should see user with name 'sonar'

    4. To verify the database has been created: show databases; you should see database with name 'sonar'

  2. Set buffer pool size to 50-80% of your computer's memory. Add the following to my.cnf and then restart mysql.

    • innodb_buffer_pool_size = 4096M
    • innodb_buffer_pool_instances = 4
  3. give at least 15Mb to the query_cache_size parameter

    • mysql> SET GLOBAL query_cache_size =67108864;
    • mysql> SHOW VARIABLES LIKE 'query_cache_size';

Install Java

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
  • You will be prompted to accept the Oracle License Agreement.
  • Automatic set up of Java 8 environment variables: sudo apt-get install oracle-java8-set-default
  • Check Java installation: java -version

Installing the Web Server


  1. Add the relevant source entry in your /etc/apt/sources.list
    • sudo vim /etc/apt/sources.list then press o then paste deb binary/ into the new line. press ESC then write :wq! then press ENTER
  2. sudo apt-get update
  3. sudo apt-get install sonar
  4. You may get the following warning: 'The following packages cannot be authenticated!'. Enter y to continue with the installation.
  5. ensure user is created "Adding new user 'sonar' (UID 107) with group 'nogroup'"
  6. set sonar user password. sudo passwd sonar

Configure Database

  1. cd /opt/sonar/conf

  2. sudo vi

  3. Comment out the embedded database H2 lines if needed.

  4. Uncomment the lines for the relevant database. Example below. Change server hostname or port if required.

    #----- MySQL 5.x
  5. Add/edit the following properties:


Configure WebServer

  • sudo vi /opt/sonar/conf/


Start WebServer

  • For starting the server sudo /opt/sonar/bin/linux-x86-64/ start
  • For stopping the server sudo /opt/sonar/bin/linux-x86-64/ stop
  • tail -f /opt/sonar/logs/sonar.log
  • ps -ef | grep sonar


  1. wget

  2. tar -zxf apache-maven-3.2.3-bin.tar.gz

  3. sudo mv apache-maven-3.2.3 /usr/local/

  4. Create a symbolic link to /usr/bin using the following command sudo ln -s /usr/local/apache-maven-3.2.3/bin/mvn /usr/bin/mvn

  5. Set up environment variables

    1. Create a script: sudo vim /etc/profile.d/

    2. Add the following commands to the script:

      export M2_HOME=/usr/local/apache-maven-3.2.3
      export M2=$M2_HOME/bin
      export PATH=$M2:$PATH
    3. sudo chmod 755

  6. Edit $M2_HOME/conf/settings.xml

                    <!-- Example for MySQL-->
                    <!-- Optional URL to server. Default value is http://localhost:9000 -->

This comment has been minimized.

Copy link

@seanmbowen seanmbowen commented Jan 5, 2018



This comment has been minimized.

Copy link

@cig0 cig0 commented Mar 18, 2019

Works great, thanks


This comment has been minimized.

Copy link

@harshblog150 harshblog150 commented May 30, 2019

great thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment