Usually, one jetty deploys a java web application, but deploying only one application for a service may cause a waste of resources, so sometimes multiple web applications may be deployed on a server. Below we take one server to deploy two web applications as an example.
Server environment: install JDK, 2 jetyy9
Key points: 2 The ports of each web application must not conflict.
Project 1 uses jetty01, rename bin/jetty.sh to bin/jetty01.sh, and modify its configuration as follows (Note that you do not need to configure JETTY_RUN Variables):
JETTY_HOME=/usr/local/jetty01JETTY_BASE=$JETTY_HOMEJETTY_USER=wwwJETTY_ARGS=jetty.port=8181JAVA=/usr/local/ jdk7/bin/javaJAVA_OPTIONS="-Xloggc:/opt/logs/ugcRank/gc.log -XX:+PrintGCDetails-XX:+PrintGCDateStamps"
Project 2 Use jetty02, rename bin/jetty.sh to bin/jetty02.sh, and modify the configuration:
JETTY_HOME=/usr/local/jetty02JETTY_BASE=$ JETTY_HOMEJETTY_USER=wwwJETTY_ARGS=jetty.port=8282JAVA=/usr/local/jdk7/bin/javaJAVA_OPTIONS="-Xloggc:/opt/logs/vrsRank/gc.log-XX:+PrintGCDetails-XX:+PrintGCDateStamps"
At this time, the pids of the two jetty are located in the default directory, namely /var/run, and the paths are respectively /var/run/ jetty/jetty01.pid, /var/run/jetty/jetty02.pid.
The second way: modify the directory where the pid file is saved. The directory is configured by JETTY_RUN and is in /var by default /run/jetty, such as:
Project 1 uses jetty01, modify bin/jetty02.sh as follows:
JETTY_HOME=/usr/local/jetty01JETTY_BASE=$JETTY_HOMEJETTY_RUN=$JETTY_BASEJETTY_USER=wwwJETTY_ARGS=jetty.port=8181JAVA=/usr/local/jdk7/bin/javaJAVA_OPTIONS="copt-Xloggc:/javaJAVA_OPTIONS="copt-Xloggc: /gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps"
Project 2 uses jetty02, modify bin/jetty02.sh as follows:
JETTY_HOME=/usr/local/jetty01JETTY_BASE=$JETTY_HOMEJETTY_RUN=$JETTY_BASEJETTY_USER=wwwJETTY_ARGS=jetty.port=8181JAVA=/usr/local/jdk7/bin/javaJAVA_OPTIONS="-Xloggc:/copt/loggc:/copt/loggc: log -XX:+PrintGCDetails -XX:+PrintGCDateStamps"
At this time, the pid file is located in the installation directory of the respective jetty. Although they are all jetty.pid, they do not affect each other.
Configure jetty as a system service< /span>
First, copy bin/jetty.sh to /etc/init.d:
cp bin/jetty.sh /etc/init.d/jetty
Then create a new file /etc/default/jetty and set the environment variable JETTY_HOME in it:< /p>
$ vim /etc/default/jettyJETTY_HOME=/usr/local/jetty9.1
Start and stop:
< pre class="brush:bash;toolbar:false">$ service jetty start$ service jetty stop
Note: bin/jetty.sh uses /etc/default/{pid} as its configuration file by default. At this time, the pid name is jetty, so /etc/default/jetty will be used as jetty’s configuration file, in which environment variables such as JETTY_HOME, JAVA, JAVA_OPTIONS, etc. can be configured.
Reposted from: https://nkcoder.github.io/2014/06/18/jetty-deploy-help/
< p>