7.3.5. WAR deployment to Tomcat Linux Service
The example below has been tested on Ubuntu 16.04
-
Add the buildWar task to the end of build.gradle. You can also specify a different
context.xmlfile to setup the connection to the production database:task buildWar(type: CubaWarBuilding) { appHome = '${catalina.base}/work' singleWar = true includeContextXml = true includeJdbcDriver = true appProperties = ['cuba.automaticDatabaseUpdate': true] webXmlPath = 'modules/web/web/WEB-INF/single-war-web.xml' coreContextXmlPath = 'modules/core/web/META-INF/war-context.xml' }If the target server parameters differ from what you have on the local Tomcat used for fast deployment, provide appropriate application properties. For example, if the target server runs on port 9999, the task definition should be as follows:
task buildWar(type: CubaWarBuilding) { appHome = './app_home' singleWar = false includeContextXml = true includeJdbcDriver = true appProperties = [ 'cuba.automaticDatabaseUpdate': true, 'cuba.webPort': 9999, 'cuba.connectionUrlList': 'http://localhost:9999/app-core' ] } -
Run the
buildWargradle task. As a result,app.warfile will be generated in thebuild/distibutionsdirectory of your project.gradlew buildWar -
Install Tomcat 8 Linux Service:
sudo apt-get install tomcat8 -
Copy the generated
app.warfile to the empty/var/lib/tomcat8/webappsdirectory of the server.TipTomcat service runs from
tomcat8user by default. The owner ofwebappsfolder istomcat8as well. -
Create configuration file
/usr/share/tomcat8/bin/setenv.shwith the following text:export CATALINA_OPTS="$CATALINA_OPTS -Xmx1024m" -
Restart the Tomcat service:
sudo service tomcat8 restart -
Open
http://localhost:8080/appin your web browser.