系统环境:
[[email protected] etc]# uname -a Linux ORACLE 2.6.18-308.el5 #1 SMP Fri Jan 27 17:17:51 EST 2012 x86_64 x86_64 x86_64 GNU/Linux [[email protected] etc]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 5.8 (Tikanga)
软件版本:
jetty-distribution-8.1.16.v20140903.tar.gz
jdk-7u75-linux-x64-demos.gz
httpd-2.2.29.tar.gz
前面我的实验环境apache和jetty都已安装完毕,这里不在介绍jetty安装,有需要的请查看我的jetty安装博客
前面我有做apache和tomcat的整合,tomcat和jetty的默认端口都是8080,所以,这里我需要更改jetty的端口:
修改jetty的etc文件下面的jetty.xml文件:
###将8080端口改为了8900 <Call name="addConnector"> <Arg> <New class="org.eclipse.jetty.server.nio.SelectChannelConnector"> <Set name="host"><Property name="jetty.host" /></Set> <Set name="port"><Property name="jetty.port" default="8900"/></Set> <Set name="maxIdleTime">300000</Set> <Set name="Acceptors">2</Set> <Set name="statsOn">false</Set> <Set name="confidentialPort">8443</Set> <Set name="lowResourcesConnections">20000</Set> <Set name="lowResourcesMaxIdleTime">5000</Set> </New> </Arg> </Call>
查看apache和jetty运行状态:
[[email protected] data]# ps -ef|grep httpd root 3828 1 0 11:37 ? 00:00:00 /var/data/apache/bin/httpd -k start apache 3829 3828 0 11:37 ? 00:00:00 /var/data/apache/bin/httpd -k start apache 3830 3828 0 11:37 ? 00:00:00 /var/data/apache/bin/httpd -k start apache 3831 3828 0 11:37 ? 00:00:00 /var/data/apache/bin/httpd -k start apache 3832 3828 0 11:37 ? 00:00:00 /var/data/apache/bin/httpd -k start apache 3833 3828 0 11:37 ? 00:00:00 /var/data/apache/bin/httpd -k start apache 3834 3828 0 11:38 ? 00:00:00 /var/data/apache/bin/httpd -k start root 4006 3517 0 13:47 pts/0 00:00:00 grep httpd [[email protected] data]# ps -ef|grep java root 3944 1 0 11:41 pts/0 00:00:10 /usr/local/jdk1.7/bin/java -Djetty.state=/usr/local/jetty/jetty.state -Djetty.home=/usr/local/jetty -Djava.io.tmpdir=/tmp -jar /usr/local/jetty/start.jar etc/jetty-logging.xml etc/jetty-started.xml root 4008 3517 0 13:47 pts/0 00:00:00 grep java
查看端口:
[[email protected] etc]# netstat -tpln|grep java tcp 0 0 :::8900 :::* LISTEN 3944/java [[email protected] etc]# netstat -tpln|grep httpd tcp 0 0 :::80 :::* LISTEN 3828/httpd
jetty启动方法:
/usr/local/jetty/bin/jetty.sh start --启动
/usr/local/jetty/bin/jetty.sh stop --关闭
验证jetty是否启动成功,访问http://127.0.0.1:8900
Welcome to Jetty 8 - REMOTE ACCESS!!
如上图显示,则表示jetyy已启动成功
将apache和jetty整合,静态的文件通过apache访问,动态的通过jetty访问。
这里我通过http_proxy进行实现
修改httpd.conf文件,这里修改和apache+tomcat整合(二)一样,需要加载proxy模块:
#加载需要模块: LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_connect_module modules/mod_proxy_connect.so LoadModule proxy_http_module modules/mod_proxy_http.so LoadModule proxy_ajp_module modules/mod_proxy_ajp.so LoadModule proxy_balancer_module modules/mod_proxy_balancer.so LoadModule rewrite_module modules/mod_rewrite.so #当访问1文件夹时,将其转发给jetty处理: ProxyPass /1 http://localhost:8900/1 ProxyPassReverse /1 http://localhost:8900/1
我们需要在jetty的webapps文件夹下面创建1目录,如下图:
[[email protected] etc]# ll ../webapps/1/ total 4 -rw-r--r-- 1 root root 94 Apr 9 14:00 hello.jsp
验证,访问http://IP/1:
总结:总的来说apache+tomcat和apache+jetty其实方法差不多,环境已经搭建好,接下来就是服务器的优化方面,后面需要继续加油~~~
时间: 2024-10-08 00:24:03