系統環境:java
[root@ORACLE 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 [root@ORACLE etc]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 5.8 (Tikanga)
軟件版本:linux
jetty-distribution-8.1.16.v20140903.tar.gzweb
jdk-7u75-linux-x64-demos.gzapache
httpd-2.2.29.tar.gz tomcat
前面個人實驗環境apache和jetty都已安裝完畢,這裏不在介紹jetty安裝,有須要的請查看個人jetty安裝博客服務器
前面我有作apache和tomcat的整合,tomcat和jetty的默認端口都是8080,因此,這裏我須要更改jetty的端口:app
修改jetty的etc文件下面的jetty.xml文件:eclipse
###將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運行狀態:webapp
[root@ORACLE 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 [root@ORACLE 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
查看端口:jsp
[root@ORACLE etc]# netstat -tpln|grep java tcp 0 0 :::8900 :::* LISTEN 3944/java [root@ORACLE 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
如上圖顯示,則表示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目錄,以下圖:
[root@ORACLE 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其實方法差很少,環境已經搭建好,接下來就是服務器的優化方面,後面須要繼續加油~~~