|
Talk about installing JDK and configure Jetty server in Ubuntu 14.04.2 process, the first step to get JDK installation file, because my system is 64-bit, so the installation package is jdk-7u80-linux-x64. gz
Uploaded to Ubuntu server
Executive tar -xvf jdk-7u80-linux-x64.gz, extract to the current directory
tar -xvf jdk-7u80-linux-x64.gz
We then move to the directory / usr / lib / jvm below
mv jdk1.7.0_80 /usr/lib/jvm/jdk1.7.0_80
Jdk directory using the chmod command to increase the executable permissions
sudo chmod u + x /usr/lib/jvm/jdk1.7.0_80/bin
Then set the environment variable JDK also can refer to:
-------------------------------------------------- -------------
Under JDK settings (three configurations environment variable method) Linux environment variables
1. Modify / etc / profile file
This is the recommended method if your computer just as a development because all users have the right to use the shell environment variables that may give the system security issues.
Open the / etc / profile with a text editor
- In the profile file is added at the end:
JAVA_HOME = / usr / share / jdk1.5.0_05
PATH = $ JAVA_HOME / bin: $ PATH
CLASSPATH =:. $ JAVA_HOME / lib / dt.jar: $ JAVA_HOME / lib / tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
- re-register
- Help
a. You want /usr/share/jdk1.5.0_05jdk to your jdk installation directory
b. linux under the colon ":" to separate path
c. $ PATH / $ CLASSPATH / $ JAVA_HOME is used to refer to the original value of the environment variables when setting environment variables in particular should be careful not to overwrite the original value to, and this is a common mistake.
d. CLASSPATH in the current directory. "" can not lose, lose the current directory is also a common mistake.
e. export is exporting these three variables as global variables.
f. case must be strictly distinguished.
2. Modify the .bashrc file
This method is more secure, it can have permission to use these environmental variables to control user level, if you need to use these environmental variables to a user permissions, you only need to modify the .bashrc file their personal user home directory can a.
Open the .bashrc file user directory with a text editor
- At the end of the file .bashrc added:
set JAVA_HOME = / usr / share / jdk1.5.0_05
export JAVA_HOME
set PATH = $ JAVA_HOME / bin: $ PATH
export PATH
set CLASSPATH =:. $ JAVA_HOME / lib / dt.jar: $ JAVA_HOME / lib / tools.jar
export CLASSPATH
- re-register
3. Set directly in the shell variable
Not in favor of using this method, because another shell, you set is invalid, this method is only for temporary use, to be used later when you want to reset too much trouble.
Just execute the following command in a terminal shell:
export JAVA_HOME = / usr / share / jdk1.5.0_05
export PATH = $ JAVA_HOME / bin: $ PATH
export CLASSPATH =:. $ JAVA_HOME / lib / dt.jar: $ JAVA_HOME / lib / tools.jar
After the Open Terminal, type the command "java -version", if the JDK version, suggesting that the environment variable configuration was successful.
-------------------------------------------------- -------------
sudo vi / etc / profile
In the profile is not added to the end of
Save and exit
Because there may be a default JDK, as openJdk ubuntu, so, then set the default JDK
update-alternatives --install / usr / bin / java java /usr/lib/jvm/jdk1.7.0_80/bin/java 300
update-alternatives --install / usr / bin / javac javac /usr/lib/jvm/jdk1.7.0_80/bin/javac 300
By the above step was added to our installed JDK java menu
Through the following command to query all JDK menu
update-alternatives --list java
Then execute the following command to select the default JDK for our installed JDK
update-alternatives --config java
If you select more than one number
Next View java version numbers are correct
java -version
If correct would indicate a successful installation JDK
Then there is the jetty installation configuration
First, download the jetty on to eclipse website, since my local development environment is used jetty8, so the server can also download jetty8
jetty-distribution-8.1.17.v20150415.tar.gz
Unbuntu uploaded to server, execute the following command to extract
tar -xvf jetty-distribution-8.1.17.v20150415.tar.gz
Jetty and then move to the next directory / opt / jetty
mv jetty-distribution-8.1.17.v20150415 / opt / jetty
To create the user jetty next to the configuration files, and set it to / opt / jetty directory host
sudo useradd jetty -U -s / bin / false
sudo chown -R jetty: jetty / opt / jetty
Next, copy the script to the jetty startup directory, run it as a service
cp /opt/jetty/bin/jetty.sh /etc/init.d/jetty
Next step is to create the jetty profile
sudo vi / etc / default / jetty
Save and Exit
Then you can use the command to start the Jetty service
sudo service jetty start
I had originally because of jdk installed ubuntu, so no installation JDk operation, but when you start, can not find the JDK always displayed, because the default JDK version is not correct, you need to change the default JDK implementation of the above operations, which started on not being given the
At this point, the server installation is complete
Next, configure your site's directory on the server
Jetty configuration files are placed in $ {JETTY_HOME} / etc directory
By $ {JETTY_HOME} /etc/jetty-webapps.xml file, you can see all of the default Jetty web app are on the $ {JETTY_HOME} / webapps directory
Jetty in the package with a default test.war application, $ {JETTY_HOME} can find this file under / webapps directory, when the default start Jetty and services have been deployed test.war applications. For test.war file, Jetty file also defines the context, on the $ {JETTY_HOME} /contexts/test.xml, which contextPath defined as a "/", which is why the default access http: // localhost: 8080 / a when is the reason why the application of the access test.
Deploy new web applications
For war deployment package, just to war file into the $ {JETTY_HOME} / webapps directory, and can be accessed directly through the browser
For web application deployment directory, then you can copy the web application directory to $ {JETTY_HOME} / webapps / under < myapp> directory, then in $ {JETTY_HOME} / contexts / < myapp> .xml file, which reads as follows
< ? Xml version = "1.0" encoding = "ISO-8859-1"?>
< ! DOCTYPE Configure PUBLIC "- // Jetty // Configure // EN" "http://www.eclipse.org/jetty/configure.dtd">
< Configure class = "org.eclipse.jetty.webapp.WebAppContext">
< Set name = "contextPath"> / myapp < / Set>
< Set name = "war"> < SystemProperty name = "jetty.home" default = "." /> / Webapps / myapp < / Set>
< / Configure> |
|
|
|