How to set up Atlassian JIRA on Amazon EC2 in 15 minutes
This post will take you through setting up JIRA on an AWS Linux instance, as part of setting up Atlassian’s Continuous Integration toolset. There are 6 steps and the whole tutorial should take around 15 minutes to complete:
1. Setup LAMP on server;
2. Create and Configure MySQL;
3. Login to MySQL and setup JIRA DB;
4. Install JIRA;
5. Install MySQL Driver;
6. Configure JIRA using Wizard;
I was doing this out of interest and read individual articles, blogs and help pages, but was unable to find a single source to guide me through the full process. The below started off as a self-reference. I have tried to refine to be understandable, and have referenced articles I used that may be helpful if you have any further specific queries.
The only prerequisite is that you have an Amazon EC2 Instance is set up (see ‘Getting Started with Amazon EC2 Instances for Linux’).
I’m far from an AWS expert, so if you have any technical questions it is unlikely I can help, but please feel free to leave feedback. Thanks and enjoy!
1. Setup LAMP on server
First step is to perform some basic setup on your AWS instance. The section below will show you how to do this quickly, but I used this article – http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html – to guide me through this.
1.1 – Connect to your instance via Terminal or SSH application.
1.2 – Ensure your AWS server is fully updated with the latest patches and releases:
sudo yum update
1.3 – Install Apache, MySQL and PHP on your Amazon instance by running the following:
sudo yum groupinstall -y 'Web Server' 'MySQL Database' 'PHP Support'
1.4 – Next, install the php-mysql package:
sudo yum install -y php-mysql
1.5 – Start the Apache web server.
sudo service httpd start
1.6 – As a precaution, check if the Apache web server is running ok by running the following two commands:
sudo chkconfig httpd on
chkconfig -list httpd
1.7 – If everything looks OK, you can open a web browser and then navigate to the Elastic IP address associated with your Amazon Instance. Here, you should see an Apache test page – this confirms that LAMP has been setup OK.
2. Create and Configure MySQL
The second step is to configure MySQL – the underlying database that Stash will use to store settings and data. For more info see ‘Atlassian: Setting up a MySQL Database on Linux for JIRA’.
3.1 – Start the MySQL server:
sudo service mysqld start
3.2 – Execute the installation wizard for MySQL using the below command. When prompted, enter a password for the root account. Type ‘Y’ for all the options offered when prompted.
3. Login to MySQL and setup JIRA DB
Now that MySQL is running, it is time to set up the database that JIRA needs, and also a user for JIRA so that it can access the database.
3.1 – Login to MySQL using terminal and your admin details created in step 3 above.
mysql -u root -p
3.2 – Create the JIRA DB
CREATE DATABASE jiradb CHARACTER SET utf8 COLLATE utf8_bin;
3.3 – Create the JIRA User with appropriate access rights
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX on jiradb.* TO 'jirauser'@'localhost' IDENTIFIED BY 'password50';
3.4 – Refresh MySQL privileges then exit:
3.5 – Validate that the database was setup correctly by logging back in:
mysql \--user=jirauser \--password=password50 \--database=jiradb
3.6 – User should be able to log in OK.
4. Install JIRA
The fourth step is to download and install JIRA on your AWS instance. Atlassian provide an installer file from their site that will do all the leg work.
4.1 – Download the JIRA installer direct to your AWS instance:
4.2 – Create a jira folder:
4.3 – Move installer to newly created JIRA folder:
mv atlassian-jira-6.1.5-x64.bin jira
4.4 – Move to jira folder ‘cd jira’ and use ‘ls’ to test that the file is in there OK
4.5 – Set run privileges on file, so you can install it:
chmod +x atlassian-jira-6.1.5-x64.bin
4.6 – Install the JIRA file by running:
5. Install Atlassian MySQL Driver
If you want JIRA to use MySQL you need to download a Java/MySql connector (required for most Atlassian integrations to MySQL).
6.1 – Download the files to run the connector:
6.2 – Unzip the file:
tar -zxvf mysql-connector-java-5.1.34.tar.gz
6.3 – Copy the connector .jar file from the unzipped folder into your JIRA ‘lib’ folder
cp mysql-connector-java-5.1.34/mysql-connector-java-5.1.34-bin.jar ../atlassian/jira/lib
6.4 – Restart JIRA:
6. Configure JIRA using Wizard
JIRA has been setup and restarted, now the only thing that remains is to set it up using the JIRA wizard.
6.1 – JIRA is now up and running on your AWS. Open a web browser and navigation to http://<your AWS Elastic IP Address>:8080.
6.2 – You should see a JIRA first-time setup page.
6.3 – Specify that you want to define the database connect to (should be radio button), then attempt to connect to the MySQL DB using credentials setup earlier in Section 3. I used ‘localhost’ in hostname field to do this.
6.4 – Once you have filled all fields, click on ‘Test Connection’ to see if JIRA can connect and login to the ‘jiradb’ setup above.
6.5 – If ‘Test Connection’ works, then click ‘Next’ and follow the rest of the setup wizard. At the end you will have created an admin user for JIRA, and completed the setup. After that it is good to be used at http://<your AWS Elastic IP Address>:8080. Note: you will have to create an atlassian ID and either use an evaluation license, or buy one, as part of the rest of this wizard.
6.6 – If you receive an error on the first page, then welcome to my world for the first 15 times I tried it! It took me a while to figure it out, but here are the issues that I hit and what the resolution was to them.
Potential issues you may encounter…
- If you cannot connect to JIRA instance in web browser…
- Check that your AWS Security Group is configured to allow your machines’ IP address to access port 8080 on your elastic IP.
- If JIRA crashes early on or mid-way through setup…
- You may be hitting the limit of your AWS instance’s memory. I found that the micro tier EC2 instance (instance type: ‘t1.micro’) didn’t work for me, so I had to repeat all the above steps on a larger, paid for, AWS Linux instance (I used instance type: ‘c3.large’);
- If having a problem when clicking ‘Test Connection’…
- Check the host name you are using in point 6.3. If you are not using ‘localhost’, check that the IP address you are using is in your AWS Instance’s Security Group. You will need to ensure that you AWS instance allows inbound calls to port 3306.
- Check that the JIRA connector driver is in the correct folder.
- If you get a MySQL user access error that stops you from connecting, try creating a new user with admin rights as per this link – http://stackoverflow.com/questions/1559955/host-xxx-xx-xxx-xxx-is-not-allowed-to-connect-to-this-mysql-server.