Skip to content

4. Installation: Deploying to Tomcat

Glen Mazza edited this page Nov 9, 2025 · 9 revisions

Deploying TightBlog to the Tomcat servlet container involves creating a TightBlog configuration file, adding some jars to Tomcat and then deploying the TightBlog WAR file. Apache Tomcat needs to be installed and configured before TightBlog, and it's assumed you're aware of how to deploy a WAR archive on Tomcat. See the Tomcat documentation for more information if needed.

Create TightBlog Configuration File

Normally, just a application-tbcustom.properties file, overriding any default values desired from the distribution's application.properties file (which specifies the name of the custom file given above) is sufficient. Rarely if ever needed, but some configuration can be done by overriding Spring configuration settings with a application-tbcustom.xml file. For Tomcat, these files can simply be placed at the top-level apache-tomcat-X.Y.Z\lib folder and will be detected and used by the TightBlog war.

The below provides a sample application-custom.properties file. Good to review the application.properties file for additional fields you may wish to override, however, many (especially lesser-overridden) properties are defined within individual Java files with their defaults (for example the overridable properties in the constructor for the CommentSpamChecker.) Note you'll just need one of the three blocks shown below for database access:

# ensure the tomcat owner has execute permission on all parent folders to be able to see /mediafiles and /searchindex
mediafiles.storage.dir=/home/gmazza/tbfiles/mediafiles

# (optional) Absolute URL is your domain if WAR is ROOT, or domain/webappname otherwise.
# If not defined, TightBlog will determine based on first access at startup.
site.absoluteurl=https://www.yourdomain.com

# search.enabled only for TB's internal search functionality, use false if using Google search or no search
search.enabled=false
search.include.comments=false
#search.index.dir=/home/gmazza/tbfiles/searchindex

# Requiring Google Authentication (MFA) for logins, enabled is default
#mfa.enabled=false

#MySQL sample
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/tightblogdb?allowPublicKeyRetrieval=true&useSSL=false
spring.datasource.username=scott
spring.datasource.password=tiger

# If wanting to link in Github code via snippets, also a whitelist to guard against API being used by 3rd parties for other code
#external.github.enabled=true
# only (for me) gmazza code
#external.github.whitelist=^gmazza/.*

# Mail config sample for a gmail account, uncomment config once filled in with real data.
#If using Gmail, only the following two properties need be defined (rest configured in parent tightblog.properties)
#spring.mail.username=blah.blah@gmail.com
#spring.mail.password=blahspassword

#If not using Gmail, configure these values additionally
#spring.mail.host=smtp.gmail.com
#spring.mail.port=587
#spring.mail.properties.mail.smtp.auth = true
#spring.mail.properties.mail.smtp.starttls.enable = true
#spring.mail.properties.mail.smtp.socketFactory.class = javax.net.ssl.SSLSocketFactory
#spring.mail.properties.mail.smtp.connectiontimeout = 60000
#spring.mail.properties.mail.smtp.timeout = 60000

# If using Akismet for comment moderation
#commentSpamChecker.akismet.apiKey=xxxxx
#commentSpamChecker.akismet.enabled=true

Notes:

  • The Java mail properties are explained in this Baeldung article. Note the email account defined above will appear in the “From:” line of notification email messages sent to blog owners (and, if they select “Notify me of further comments”, blog commenters) so take care not to use a email account you wish to keep private.

Add MySQL JDBC Driver JAR to Tomcat

  • Normally mysql-connector-java-8.x.x.jar for MySQL. Once in the Tomcat classpath, TightBlog's database subsystem will be able to find and use it.

Tomcat: Set URI Encoding

TightBlog supports internationalization (I18N), but on Tomcat some additional configuration is necessary. You must ensure that Tomcat's URI encoding is set to UTF-8. You can do this by editing the Tomcat configuration file conf/server.xml and adding URIEncoding=”UTF-8” to each connector element, as shown below:

   <Connector port="8080" maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
      enableLookups="false" redirectPort="8443" debug="0" acceptCount="100"
      connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="UTF-8" />

Make sure you do this for every connector through which you use TightBlog. For example, if you use the AJP connector or HTTPS connector you need to add the URIEncoding="UTF-8" attribute to those connectors as well.

Tomcat: Setup SSL

TightBlog's WAR is configured to use SSL on every page by default, make sure you follow the Tomcat Guide to activate SSL on the container.

Tomcat: Deploy TightBlog

Refer to the Tomcat documentation for information on the various ways to deploy a WAR. By renaming the TightBlog WAR to tightblog.war and placing it in the webapps directory of a running Tomcat instance (one method), you should be able to access TightBlog at https://mydomain:port/tightblog. Or, rename it to ROOT.war to access the application from https://mydomain:port/` alone.

Start TightBlog!

Finally, navigate to the application from a browser to complete the installation: setting up the admin account, setting server runtime config options, and creating your first blog. If you're deploying TightBlog, don't delay the initial configuration steps, the website will otherwise be open to anybody to configure themselves as admin and create blogs themselves.

If you cannot get the application to appear from the browser, check Tomcat's log/catalina.out log file to see any issues. A common startup problem will be incorrect database configuration settings, please review the Wiki page on database setup for assistance if necessary.

Clone this wiki locally