Tuesday 1 August 2017

JIRA Server installation

These are the steps I went through to install and configure a TEST/DEMO Jira Server on Microsoft Azure Windows VM in the cloud.
We will also be importing from Mantis (MySQL) to test the migration process.

Azure VM

  1. Provision an Azure VM, DS2_V2. We won't be keeping it up 24/7 so price doesn't matter too much. Note: I used Windows 2016 Datacentre
  2. Create a DNS name <something>.fnzbasakljira.australiasoutheast.cloudapp.azure.com so you never need to look at the IP address (but we do - later).
  3. Configure network security group to allow ports 80/443. 80 for free SSL, 443 for actual secure use later.
  4. Log onto VM
  5. What I always do: Turn off IESC and install the ubiquitous tools - Notepad++, 7-Zip
  6. In Windows Firewall, add an inbound rule to allow HTTP/S (TCP 80, 443)
JIRA (v7.4.2#74004)
  1. Download and install JIRA - choose the Express/Demo option
  2. Use the custom/expert mode
  3. Follow the steps to create a key for a 90 day trial
  4. Choose port 80 instead of 8080
SSL
  1. Create a DNS record to point to the VM's IP address
  2. Go to https://sslforfree.com and follow the steps to create a certificate
  3. Use the option for Manual Verification
  4. On the Azure VM, create the folder structure C:\Program Files\Atlassian\JIRA\well-known\acme-challenge\FeDY-uMBdrY4SWhoTjwCe7XT9lXxv7nKNUW9b_wOUV0 where the last folder name is the name of the file expected, e.g. 
    1. http://my.domain.com/.well-known/acme-challenge/FeDY-uMBdrY4SWhoTjwCe7XT9lXxv7nKNUW9b_wOUV0/
  5. In the folder, save the file ("Download file #1") from the SSLforFree verification link and rename it as index.htm
  6. Edit the file C:\Program Files\Atlassian\JIRA\conf\server.xml and add this line before the similar <Context path="" line
    1. <Context path="/.well-known" docBase="${catalina.home}/well-known" reloadable="false" useHttpOnly="true" />
  7. Click "Download SSL Certificate"
  8. Click "Download All SSL Certificate Files" on the next page
  9. You now have certificate.crt, private.key and ca_bundle.crt
  10. Download OpenSSL binaries for Windows. I used the slproweb link from https://wiki.openssl.org/index.php/Binaries
  11. For the next step, easier to copy the 3 files into the same folder as openssl.exe, then delete them after.
  12. Run the command line (in openssl.exe folder) (you can change the highlighted name):

    C:\OpenSSL-Win32\bin>openssl pkcs12 -export -in certificate.crt -inkey private.key -out cert.p12 -name SSLForFree -CAfile ca_bundle.crt -caname root
  13. Then, in the cmd.exe console swith to JIRA's JRE bin folder and run this:

    keytool -importkeystore -deststorepass changeit -destkeystore "C:\Program Files\Atlassian\JIRA\jre\lib\security\cacerts" -srckeystore C:\OpenSSL-Win32\bin\cert.p12 -srcstoretype PKCS12 -srcstorepass yourPfxPassword

    keytool -storepasswd -new yourPfxPassword -keystore "C:\Program Files\Atlassian\JIRA\jre\lib\security\cacerts"

    Using your password from step 12
  14. In cmd.exe, set the environment variable for Java

    SET JRE_HOME=C:\Progra~1\Atlassian\JIRA\jre
  15. Run the JIRA configuration utility

    C:\Program Files\Atlassian\JIRA\bin>config.bat
  16. In the Web Server tab, change:

    Profile: HTTP and HTTPS (redirect)
    HTTPs Port: 443
    Keystore Path: 
    C:\Program Files\Atlassian\JIRA\jre\lib\security\cacerts
    Keystore Password: yourPfxPassword
  17. Use "Check Certificate in Key Store" button to ensure everything is correct before clicking Save then Close
  18. As at 2nd August 2017, the JIRA configuration utility puts the wrong connector into the server.xml (see step 6 for path) file when HTTPS is enabled. Look for org.apache.coyote.http11.Http11Protocol and change it to org.apache.coyote.http11.Http11NioProtocol 
  19. Finally, we can use the batch files in C:\Program Files\Atlassian\JIRA to recycle JIRA

    stop_service.bat
    start_service.bat
MySQL (5.7.19)
  1. Download an installer package from https://dev.mysql.com/downloads/
    1. Community Server
    2. Installer (instead of Zip file)
  2. Search on Google for "visual studio 2013 c++ redistributables", download and install
    1. The installer seems to have a provision to locate and install, but it didn't work for me
  3. We only need the server and command line tools, but I wasn't sure if MySQL Server (only) includes the command line tools, so I used Custom, then chose MySQL Server X64, then ticked only
    1. MySQL Server
      1. Client Programs
    2. Server data files
  4. Click Next, then Execute
  5. Choose (where not specified, use defaults, and provide your own root password)
    1. "Standalone MySQL Server"
    2. Config Type: Server Machine
  6. Complete installation
Mantis
  1. Paste the MySQL dump file into the MySQL bin folder, e.g. C:\Program Files\MySQL\MySQL Server 5.7\bin
  2. Run MySQL command line from C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -u root -p
  3. In MySQL, run the following commands to create a new db and restore from dump (change the file name):

    mysql> create database mantis;
    mysql> use mantis;
    mysql> source dumpfilename.sql;
  4. Note: I had to 
Import Mantis to JIRA
  1. As per https://confluence.atlassian.com/adminjiraserver074/connecting-jira-applications-to-mysql-881683181.html, download the MySQL connector from https://dev.mysql.com/downloads/connector/j/
  2. Get the mysql-connector-java-5.1.43-bin.jar (any version) from the zip file and paste into C:\Program Files\Atlassian\JIRA\lib
  3. Stop and start JIRA service
  4. Use the menu item, Create Project -> Import and follow the steps