Install JDK under Ubuntu14.02.2 and configure the Jetty server, ubuntu14.02.2jetty
Bytes
Upload to the unbuntu Server
Run the tar-xvf jdk-7u80-linux-x64.gz and unzip it to the current directory
tar -xvf jdk-7u80-linux-x64.gz
Then we move the directory to/usr/lib/jvm.
mv jdk1.7.0_80 /usr/lib/jvm/jdk1.7.0_80
Run the chmod command to add executable permissions to the jdk directory.
sudo chmod u+x /usr/lib/jvm/jdk1.7.0_80/bin
Then set JDK environment variables, you can also refer to this URL: http://www.blogjava.net/jak/archive/2008/04/01/190069.html
sudo vi /etc/profile
Add a profile before it ends
Save and exit
Because ubuntu may have a default JDK, such as openJdk, set the default JDK.
update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_80/bin/java 300update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_80/bin/javac 300
Add the JDK we installed to the java menu through the above step.
You can run the following command to query all JDK menus:
update-alternatives --list java
Next, run the following command to select the JDK installed by default.
update-alternatives --config java
Select the serial number if there are multiple
Next, check whether the java version is correct.
java -version
If correct, the JDK is successfully installed.
Next, install and configure jetty.
First, download jetty from the eclipse website. Because my local development environment uses jetty8, the server also downloads jetty8.
Jetty-distribution-8.1.17.v20150415.tar.gz
After uploading to the unbuntu server, run the following command to decompress
tar -xvf jetty-distribution-8.1.17.v20150415.tar.gz
Then move the jetty directory to/opt/jetty.
mv jetty-distribution-8.1.17.v20150415 /opt/jetty
Next, create a jetty user, use it for the configuration file, and set it to the host in the/opt/jetty directory.
sudo useradd jetty -U -s /bin/falsesudo chown -R jetty:jetty /opt/jetty
Next, copy the jetty script to the startup directory and run it as a service.
cp /opt/jetty/bin/jetty.sh /etc/init.d/jetty
Next, we will create the jetty configuration file.
sudo vi /etc/default/jetty
Add the following content
Save and exit
Then you can run the command to start the Jetty service.
sudo service jetty start
If it is normal, the following page is displayed:
I did not install jdk because I had installed JDk on ubuntu, but I still cannot find JDK at startup because the default JDK version is incorrect, you need to perform the default JDK change operation above, so that no error will be reported during startup.
So far, Server installation is complete
Next, configure your website directory to the server.
All Jetty configuration files are stored in the $ {JETTY_HOME}/etc directory.
From the $ {JETTY_HOME}/etc/jetty-webapps.xml file, we can see that Jetty places all web apps under the $ {JETTY_HOME}/webapps directory by default.
The Jetty package contains a test by default. for war applications, you can find this file in the $ {JETTY_HOME}/webapps directory. By default, test is deployed when the Jetty service is started. war application. For test. war file, Jetty also defines the context file, put it in $ {JETTY_HOME}/contexts/test. in xml, contextPath is defined as "/", which is why the test application is accessed by default when http: // localhost: 8080/is accessed.
Deploy new web Applications
To deploy a war package, you only need to put the war file under the $ {JETTY_HOME}/webapps directory, and then you can directly access it through a browser.
For web application directory deployment, you can copy the web application directory to the $ {JETTY_HOME}/webapps/<myapp> directory, then in $ {JETTY_HOME}/contexts/<myapp>. xml file with the following content:
<?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>
Restart the Jetty service and access http: // localhost: 8080/myapp to view the newly deployed web application.