Friday, October 2, 2015

Installing Kill Bill on Ubuntu 14.04 with Tomcat 7.

I'm not a Java guy, and the guides out there seem to assume knowledge of deploying Java apps, so this took me a some time to get right, so I'm going to document the steps I took here.

sudo apt-get install mysql-server mysql-client default-jdk tomcat7 tomcat7-common tomcat7-admin libmysql-java

Kill Bill uses odd minor numbers for developing new features and even minor numbers for production releases. The download page http://killbill.io/downloads/. Hold off downloading anything until the instructions call for it.

First we need to initialize the mysql database. We need a user and database for the killbill application. The following assumes that the root mysql user's password is foobar, that the database will be named killbill, and that the username and password for the application will be killbill:killbill. All of these are fine defaults with the exception of the passwords. Change as needed.

mysql -u root -pfoobar
mysql> create database killbill;
mysql> create user 'killbill'@'localhost' identified by 'killbill';
mysql> grant all on killbill.* to 'killbill'@'localhost';
mysql> exit

Now we need to initialize the database with the tables. At the download page, download the corresponding ddl.sql for your version of Kill Bill.

wget http://docs.killbill.io/0.14/ddl.sql
mysql -u root -pfoobar --database=killbill < ddl.sql

Now that our database is setup we can configure Tomcat. First we need to setup credentials for the admin page. As root, open /etc/tomcat7/tomcat-users.xml and replace the contents to look like this, replacing the username and password fields with what you want to use.


<tomcat-users>
  <role rolename="manager-gui"/>
  <role rolename="tomcat"/>
  <user password="tomcat" roles="tomcat,manager-gui" username="tomcat"/>
</tomcat-users>

Next, we need to set the maximum upload to a sane value that will be sufficient for uploading the WAR file. As root, open up /usr/share/tomcat7-admin/manager/WEB-INF/web.xml and find the key max-file-size. Set the lines as follows.

    <multipart-config>
      <max-file-size>524288000</max-file-size>
      <max-request-size>524288000</max-request-size>
      <file-size-threshold>0</file-size-threshold>
    </multipart-config>

Finally we need to configure Tomcat to connect to the killbill database. As root, open up /etc/tomcat7/catalina.properties and append the following to the end of the file, changing any values as appropriate for your setup.

# Kill Bill properties
org.killbill.dao.url=jdbc:mysql://127.0.0.1:3306/killbill
org.killbill.dao.user=killbill
org.killbill.dao.password=killbill
ANTLR_USE_DIRECT_CLASS_LOADING=true

Now that everything is configured we need to restart tomcat.

sudo service tomcat7 restart

On your local machine download the WAR file from the download page and save it somewhere so we can upload it to the server in the next step.

On port 8080 of your server running tomcat browse to /manager/html/ In the section labeled "WAR file to deploy" click the "Choose File" button, select the WAR file you downloaded and then click the "Deploy" button.

When the upload is complete the page will refresh and you should see it listed in the Applications section. Finally, click the Start button next to the killbill application and you should be in business.

If the application will not start go over this guide to make sure you followed all the steps correctly. You can also look at the log files in /var/log/tomcat7/ to troubleshoot.

As of Ubuntu 15.04 the tomcat8 and openjdk-8 packages are available to install. Both of these packages should be more performant, but it is up to you to try them out if you so desire.

No comments:

Post a Comment