Merge pull request #2115 from GOLinux/master

[Translated] 20141208 Install Jetty 9 (Java servlet engine and webserver) on Ubuntu 14.10 Server.md
This commit is contained in:
joeren 2014-12-16 08:44:59 +08:00
commit 103c336cb4
2 changed files with 104 additions and 107 deletions

View File

@ -1,107 +0,0 @@
Translating by GOLinux!
Install Jetty 9 (Java servlet engine and webserver) on Ubuntu 14.10 Server
================================================================================
Jetty provides a Web server and javax.servlet container, plus support for SPDY, WebSocket, OSGi, JMX, JNDI, JAAS and many other integrations. These components are open source and available for commercial use and distribution.
Jetty is used in a wide variety of projects and products, both in development and production. Jetty can be easily embedded in devices, tools, frameworks, application servers, and clusters. See the Jetty Powered page for more uses of Jetty.
### Jetty Features ###
- Full-featured and standards-based
- Open source and commercially usable
- Flexible and extensible
- Small footprint
- Embeddable
- Asynchronous
- Enterprise scalable
- Dual licensed under Apache and Eclipse
### Install Jetty9 on ubuntu 14.10 server ###
#### Prerequisites ####
You need to install Java before installing jetty server using the following command
sudo apt-get install openjdk-8-jdk
This will install it to /usr/lib/jvm/java-8-openjdk-i386. A symlink java-1.8.0-openjdk-i386 is created in the directory /usr/lib/jvm/. A symlink is also created at /usr/bin/java
Now you need to download Jetty9 from [here][1] after downloading you need to extract using the following command
$tar -xvf jetty-distribution-9.2.5.v20141112.tar.gz
This unpacks the jetty-distribution-9.2.5.v20141112 and you need to Move the archive to /opt/jetty using the following command
$mv jetty-distribution-9.2.5.v20141112 /opt/jetty
You need to Create jetty user and make it the owner of /opt/jetty directory
sudo useradd jetty -U -s /bin/false
sudo chown -R jetty:jetty /opt/jetty
#### Jetty Startup Script ####
Copy the Jetty script to run as a service using the following command
$ cp /opt/jetty/bin/jetty.sh /etc/init.d/jetty
Now you need to create jetty settings file with the following content
sudo vi /etc/default/jetty
Add the following lines
JAVA_HOME=/usr/bin/java
JETTY_HOME=/opt/jetty
NO_START=0
JETTY_ARGS=jetty.port=8085
JETTY_HOST=0.0.0.0
JETTY_USER=jetty
Save and exit the file
You need to start jetty service using the following command
sudo service jetty start
You should see output similar to the following
Starting Jetty: OK Mon Nov 24 11:55:48 GMT 2014
If you see the following error
#### ** ERROR: JETTY_HOME not set, you need to set it or install in a standard location ####
You need to make sure you have correct jetty home path in /etc/default/jetty file i.e JETTY_HOME=/opt/jetty
You can test the jetty using the following URL
It should now be running on port 8085! Visit in your browser http://serverip:8085 and you should see a Jetty screen.
#### Jetty Service checking ####
Verify and check your configuration with the following command
sudo service jetty check
Jetty automatically start on reboot using the following command
sudo update-rc.d jetty defaults
Reboot the server and test if Jetty starts automatically.
To check which port Jetty is running or whether there are any conflicts with other programs for that port, run netstat -tln
--------------------------------------------------------------------------------
via: http://www.ubuntugeek.com/install-jetty-9-java-servlet-engine-and-webserver-on-ubuntu-14-10-server.html
作者:[ruchi][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.ubuntugeek.com/author/ubuntufix
[1]:http://download.eclipse.org/jetty/stable-9/dist/

View File

@ -0,0 +1,104 @@
Ubuntu 14.10 Server上安装Jetty 9Java服务引擎和Web服务器
================================================================================
Jetty提供了一个Web服务器和javax.servlet容器为SPDY、WebSocket、OSGi、JMX、JNDI、JAAS以及许多其它集成套件添加了支持。这些组件都是开源的也可用于商业用途和分发。
Jetty被广泛用于多种项目和产品都可以在开发环境和生产环境中使用。Jetty可以很容易地嵌入到设备、工具、框架、应用服务器以及集群中。更多用途可参见Jetty网页。
### Jetty特性 ###
- 全功能并基于标准
- 开源与商用两可
- 灵活和可扩展
- 小足迹
- 可嵌入
- 异步
- 企业弹性扩展
- Apache和Eclipse双重许可
### ubuntu 14.10 server上安装Jetty 9 ###
#### 先决条件 ####
在安装Jetty服务器前您需要通过以下命令安装Java
sudo apt-get install openjdk-8-jdk
Java将会安装到/usr/lib/jvm/java-8-openjdk-i386同时在该目录下会创建一个名为java-8-openjdk-i386的符号链接在/usr/bin/java下也会相应创建符号链接。
现在你需要从[这里][1]下载Jetty9在下载完成后你需要使用以下命令来解压缩
$tar -xvf jetty-distribution-9.2.5.v20141112.tar.gz
该操作会将它解压到jetty-distribution-9.2.5.v20141112而你需要使用以下命令将归档文件移动到/opt/jetty
$mv jetty-distribution-9.2.5.v20141112 /opt/jetty
你需要创建jetty用户并将其设置成/opt/jetty目录的属主
sudo useradd jetty -U -s /bin/false
sudo chown -R jetty:jetty /opt/jetty
使用以下命令拷贝Jetty脚本到启动目录以便让它作为一个服务来运行
$ cp /opt/jetty/bin/jetty.sh /etc/init.d/jetty
现在你需要使用以下内容来创建Jetty设置文件
sudo vi /etc/default/jetty
添加以下行
JAVA_HOME=/usr/bin/java
JETTY_HOME=/opt/jetty
NO_START=0
JETTY_ARGS=jetty.port=8085
JETTY_HOST=0.0.0.0
JETTY_USER=jetty
保存并退出该文件
你需要使用以下命令来启动Jetty服务
sudo service jetty start
你应该看到和下面类似的输出
Starting Jetty: OK Mon Nov 24 11:55:48 GMT 2014
如果你看到了下面的错误
#### ** ERROR: JETTY_HOME not set, you need to set it or install in a standard location ####
你需要确保在/etc/default/jetty文件中设置了正确的Jetty家目录路径
你可以使用以下URL来测试jetty
Jetty现在应该运行在8085端口打开浏览器并访问http://serverip:8085你应该可以看到Jetty屏幕。
#### Jetty服务检查 ####
使用以下命令来验证并检查配置
sudo service jetty check
使用以下命令来让Jetty开重启后自动启动
sudo update-rc.d jetty defaults
重启服务器并测试Jetty是否自动启动。
要检查Jetty运行在哪个端口上或者该端口是否与其它程序冲突可以运行netstat -tln
--------------------------------------------------------------------------------
via: http://www.ubuntugeek.com/install-jetty-9-java-servlet-engine-and-webserver-on-ubuntu-14-10-server.html
作者:[ruchi][a]
译者:[GOLinux](https://github.com/GOLinux)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.ubuntugeek.com/author/ubuntufix
[1]:http://download.eclipse.org/jetty/stable-9/dist/