Back to LanguageTool Homepage - Privacy - Imprint

How to set up your own instance of LanguageTool


(PatrickT) #1

What do I download to set up my own instance of LanguageTool? Where do I get it?

Thanks

P


(Daniel Naber) #2

Just download the stand-alone version of LT from https://languagetool.org. It contains languagetool-server.jar that will print its usage when called like java -jar languagetool-server.jar. Alternatively, start the stand-alone version and activate the server under Text Checking -> Options -> Run as server.


(PatrickT) #3

I tried to run languagetool-server.jar and got the following:

root@server [/home/esprimme/public_html/lt]# java -jar languagetool-server.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/languagetool/server/HTTPSServer : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

What's up here?

Patrick


(Daniel Naber) #4

You need Java 8 to run LanguageTool 3.3, it seems you're still on Java 7.


(PatrickT) #5

Thanks Daniel. I upgraded my server account and the LanguageTool server started. However, I am not able to connect through my browser or with Telnet.

P


(Daniel Naber) #6

Which URL did you use to connect? What happened then, did you get an error message?


(PatrickT) #7

Daniel:

I checked with my hosting service and they told there were two issues: the server's firewall and the need to set up a system-5 compatible (init.d) service script.

I've taken care of the firewall. However they indicate that I need an example of a service script from you. Can you help?

Thanks

P


(Daniel Naber) #8

We don't provide such a script officially, maybe someone else here one this forum can post theirs.


(Andriy) #9

Here's the file I created for my server. It's not a ready solution for you but it's a good template to start with.
You will need to adjust the start script (currently I have a script with hardcoded classpath) and when I stop I kill all java processes as I know LT is the only java process on my server. You may need to be more specific (i.e. store PID when you start and kill by that PID).
http://r2u.org.ua/data/tmp/lt


(PatrickT) #10

Setting up LanguageTool to run on one's own server is not necessarily straightforward. In my case, having a hosted virtual private server, there are some additional hoops to jump through. You will need shell access to the server root, thus most accounts that are a shared service controlled by cPanel, you will not be able to create a permanent, stable, secure instance.

There a number of things that have recommended to me by hosting service
- create a special user with no login privileges. You can see how to do this at (http://www.tecmint.com/add-users-in-linux/)
- configure your firewall to enable port 8081 (or whichever port you choose)
- a service script is needed (more on that below)

I found a template for a service script for my server--running Centos 7-- at http://appsintheopen.com/posts/41-creating-centos-or-redhat-init-scripts

I have modified the template for my installation, as follows, but there are a couple of items I'm not sure how to handle.

#!/bin/sh
#
# <ltoold> <summary>
#
# chkconfig:   - 20 80
# description: <description, split multiple lines with \
#              a backslash>

# Source function library.
. /etc/rc.d/init.d/functions

exec="java -cp /home/ltool/languagetool-server.jar org.languagetool.server.HTTPServer --port 8081"
prog="languagetool"
config="/home/ltool/"                   **<----- Is there a configuration file associated with LanguageTool?**

[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

lockfile=/var/lock/subsys/$prog

start() {
    [ -x $exec ] || exit 5
    [ -f $config ] || exit 6
    echo -n $"Starting $prog: "
    # if not running, start it up here, usually something like "daemon $exec"
#=======================
# It has been suggested that I use something like to the following to start LanguageTool
#  cd /home/ltool
#  sudo -u ltool java -cp languagetool-server.jar org.languagetool.server.HTTPServer --port 8081
# since it's multiline, I may have to put this in a file (i.e., startlt.sh)
#=======================
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}

stop() {
echo -n $"Stopping $prog: "
# stop it here, often "killproc $prog"
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}

restart() {
stop
start
}

reload() {
restart
}

force_reload() {
restart
}

rh_status() {
# run checks to determine if the service is running or use generic status
status $prog
}

rh_status_q() {
rh_status >/dev/null 2>&1
}


case "$1" in
start)
    rh_status_q && exit 0
    $1
    ;;
stop)
    rh_status_q || exit 0
    $1
    ;;
restart)
    $1
    ;;
reload)
    rh_status_q || exit 7
    $1
    ;;
force-reload)
    force_reload
    ;;
status)
    rh_status
    ;;
condrestart|try-restart)
    rh_status_q || exit 0
    restart
    ;;
*)
    echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
    exit 2
esac
exit $?

Well, that's it for now.
P