|
|
(4 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
| {{TOCright}} __TOC__ | | {{TOCright}} __TOC__ |
| | | |
− | These instructions are related to installing and running Tomcat 7 as a service, which means that will be launched at system boot and will be closed properly on system shutdown.
| + | Select your Operating System: |
− | | + | * [[Configure Tomcat service linux| Configure in Linux]] |
− | == Running as a Linux Service ==
| + | * [[Configure Tomcat service windows| Configure in Windows]] |
− | For security reasons you shouldn't run Tomcat as '''root'''. It is better to create a user named openkm and run Tomcat from him:
| |
− | | |
− | $ sudo adduser openkm
| |
− | | |
− | Create a file with the script:
| |
− | | |
− | $ sudo vim /etc/init.d/tomcat
| |
− | | |
− | <source lang="bash">
| |
− | #!/bin/sh
| |
− | | |
− | ### BEGIN INIT INFO
| |
− | # Provides: tomcat
| |
− | # Required-Start: $remote_fs $syslog
| |
− | # Required-Stop: $remote_fs $syslog
| |
− | # Default-Start: 2 3 4 5
| |
− | # Default-Stop: 0 1 6
| |
− | # Short-Description: Start and stop Apache Tomcat
| |
− | # Description: Enable Apache Tomcat service provided by daemon.
| |
− | ### END INIT INFO
| |
− |
| |
− | ECHO=/bin/echo
| |
− | TEST=/usr/bin/test
| |
− | TOMCAT_USER=openkm
| |
− | TOMCAT_HOME=/home/openkm/tomcat-7.0.27
| |
− | TOMCAT_START_SCRIPT=$TOMCAT_HOME/bin/startup.sh
| |
− | TOMCAT_STOP_SCRIPT=$TOMCAT_HOME/bin/shutdown.sh
| |
− |
| |
− | $TEST -x $TOMCAT_START_SCRIPT || exit 0
| |
− | $TEST -x $TOMCAT_STOP_SCRIPT || exit 0
| |
− |
| |
− | start() {
| |
− | $ECHO -n "Starting Tomcat"
| |
− | su - $TOMCAT_USER -c "$TOMCAT_START_SCRIPT &"
| |
− | $ECHO "."
| |
− | }
| |
− |
| |
− | stop() {
| |
− | $ECHO -n "Stopping Tomcat"
| |
− | su - $TOMCAT_USER -c "$TOMCAT_STOP_SCRIPT 60 -force &"
| |
− | while [ "$(ps -fu $TOMCAT_USER | grep java | grep tomcat | wc -l)" -gt "0" ]; do
| |
− | sleep 5; $ECHO -n "."
| |
− | done
| |
− | $ECHO "."
| |
− | }
| |
− |
| |
− | case "$1" in
| |
− | start)
| |
− | start
| |
− | ;;
| |
− | stop)
| |
− | stop
| |
− | ;;
| |
− | restart)
| |
− | stop
| |
− | sleep 30
| |
− | start
| |
− | ;;
| |
− | *)
| |
− | $ECHO "Usage: tomcat {start|stop|restart}"
| |
− | exit 1
| |
− | esac
| |
− | exit 0
| |
− | </source>
| |
− | | |
− | And make it executable:
| |
− | | |
− | $ sudo chmod 755 /etc/init.d/tomcat
| |
− | | |
− | Now update the run-levels:
| |
− | | |
− | $ sudo update-rc.d tomcat defaults
| |
− | Adding system startup for /etc/init.d/tomcat ...
| |
− | /etc/rc0.d/K20tomcat -> ../init.d/tomcat
| |
− | /etc/rc1.d/K20tomcat -> ../init.d/tomcat
| |
− | /etc/rc6.d/K20tomcat -> ../init.d/tomcat
| |
− | /etc/rc2.d/S20tomcat -> ../init.d/tomcat
| |
− | /etc/rc3.d/S20tomcat -> ../init.d/tomcat
| |
− | /etc/rc4.d/S20tomcat -> ../init.d/tomcat
| |
− | /etc/rc5.d/S20tomcat -> ../init.d/tomcat
| |
− | | |
− | start Tomcat service:
| |
− | | |
− | $ sudo service tomcat start
| |
− | | |
− | stop Tomcat service:
| |
− | | |
− | $ sudo service tomcat stop
| |
− | | |
− | It's also a good idea to configure Tomcat memory utilization. Edit the file ''$TOMCAT_HOME/bin/setenv.sh'' and edit the parameter '''JAVA_OPTS''' where you can increase the system memory managed by the JVM (Java Virtual Machine):
| |
− | | |
− | <source lang="bash" highlight="1">
| |
− | JAVA_OPTS="-Xms256m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m -Djava.awt.headless=true -Dfile.encoding=utf-8"
| |
− | JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC -Dlog4j.configuration=file://$CATALINA_HOME/conf/log4j.properties"
| |
− | CATALINA_PID=$CATALINA_HOME/catalina.pid
| |
− | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CATALINA_HOME/lib/sigar
| |
− | </source>
| |
− | | |
− | This example is for a system with 2 GB of RAM.
| |
− | | |
− | == Configure on Redhat / CentOS ==
| |
− | | |
− | $ chkconfig tomcat --level 2345 on
| |
− | | |
− | {{Note|Should be the same as in Ubuntu / Debian.}}
| |
− | | |
− | == Running as a Windows Service ==
| |
− | | |
− | {{Note|Configure OpenKM in windows as service need some extra work because are several tomcat versions depending your hardware architecture}}
| |
− | | |
− | === Step 1 - Select your tomcat ===
| |
− | | |
− | * http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.27/bin/apache-tomcat-7.0.27-windows-x86.zip
| |
− | * http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.27/bin/apache-tomcat-7.0.27-windows-x64.zip
| |
− | * http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.27/bin/apache-tomcat-7.0.27-windows-i64.zip
| |
− | | |
− | | |
− | | |
− | | |
− | | |
− | | |
− | | |
− | | |
− | Donwload and install 32-bit/64-bit Windows Service Installer from http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.27/bin/
| |
− | | |
− | Simply uncompress and overwrite openkm tomcat bundle into exiting tomcat folder.
| |
− | | |
− | {{Warning|Do not overwritten tomcat openkm bundle with tomcat windows service intaller !!!}}
| |
− | | |
− | === Known issue ===
| |
− | If you got openoffice or libreoffice configured will get some error when OpenKM try start as service, to solve it edit your general environment variable PATH and add your '''tomcat\lib\sigar\''' folder, for example like '''PATH=...;C:\Program Files\OpenKM-6.2.1\tomcat\lib\sigar'''
| |
− | <source lang="java">
| |
− | Caused by: java.lang.UnsatisfiedLinkError: org.hyperic.sigar.Sigar.getSigNum(Ljava/lang/String;)I
| |
− | at org.hyperic.sigar.Sigar.getSigNum(Native Method)
| |
− | at org.hyperic.sigar.Sigar.kill(Sigar.java:275)
| |
− | </source>
| |
| | | |
| [[Category: Installation Guide]] | | [[Category: Installation Guide]] |