wdcp添加tomcat,同時支援php和java教程_win伺服器

來源:互聯網
上載者:User

用wdcp官方提供的指令碼安裝lnamp環境,安裝請參考:http://www.wdlinux.cn/bbs/thread-6292-1-1.html,本文主要講如何在LNAMP環境下安裝JDK+Tomcat6使同一台伺服器同時支援PHP和JAVA語言。伺服器系統和各軟體版本如下所示

  1. [root@E ~]# uname -a
  2. Linux E.CentOS6.4 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
  3. [root@E ~]# /www/wdlinux/nginx/sbin/nginx -v
  4. nginx version: nginx/1.2.9
  5. [root@E ~]# /www/wdlinux/httpd-2.2.24/bin/httpd -v
  6. Server version: Apache/2.2.24 (Unix)
  7. Server built: Oct 30 2014 00:17:07
  8. [root@E ~]# rpm -qa |grep mysql
  9. mysql-libs-5.1.66-2.el6_3.x86_64
  10. [root@E ~]# /www/wdlinux/php/bin/php -v
  11. Cannot load Zend Extension Manager - it was built with configuration 1.2.0, whereas running engine is API220090626,NTS
  12. PHP 5.3.27 (cli) (built: Oct 30 2014 00:30:02)
  13. Copyright (c) 1997-2013 The PHP Group
  14. Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies

開始安裝jdk: 列出yum庫可用的jdk安裝包
  1. [root@E ~]# yum -y list java*
  2. Loaded plugins: fastestmirror
  3. Loading mirror speeds from cached hostfile
  4. * base: mirror.bit.edu.cn
  5. * extras: mirror.bit.edu.cn
  6. * rpmforge: mirrors.neusoft.edu.cn
  7. * updates: mirrors.neusoft.edu.cn
  8. base | 3.7 kB 00:00
  9. extras | 3.3 kB 00:00
  10. rpmforge | 1.9 kB 00:00
  11. updates | 3.4 kB 00:00
  12. updates/primary_db | 171 kB 00:00
  13. Available Packages
  14. java-1.5.0-gcj.x86_64 1.5.0.0-29.1.el6 base
  15. java-1.5.0-gcj-devel.x86_64 1.5.0.0-29.1.el6 base
  16. java-1.5.0-gcj-javadoc.x86_64 1.5.0.0-29.1.el6 base
  17. java-1.5.0-gcj-src.x86_64 1.5.0.0-29.1.el6 base
  18. java-1.6.0-openjdk.x86_64 1:1.6.0.33-1.13.5.0.el6_6 updates
  19. java-1.6.0-openjdk-demo.x86_64 1:1.6.0.33-1.13.5.0.el6_6 updates
  20. java-1.6.0-openjdk-devel.x86_64 1:1.6.0.33-1.13.5.0.el6_6 updates
  21. java-1.6.0-openjdk-javadoc.x86_64 1:1.6.0.33-1.13.5.0.el6_6 updates
  22. java-1.6.0-openjdk-src.x86_64 1:1.6.0.33-1.13.5.0.el6_6 updates
  23. java-1.7.0-openjdk.x86_64 1:1.7.0.71-2.5.3.1.el6 updates
  24. java-1.7.0-openjdk-demo.x86_64 1:1.7.0.71-2.5.3.1.el6 updates
  25. java-1.7.0-openjdk-devel.x86_64 1:1.7.0.71-2.5.3.1.el6 updates
  26. java-1.7.0-openjdk-javadoc.noarch 1:1.7.0.71-2.5.3.1.el6 updates
  27. java-1.7.0-openjdk-src.x86_64 1:1.7.0.71-2.5.3.1.el6 updates
  28. java-1.8.0-openjdk.x86_64 1.8.0.25-1.b17.el6 updates
  29. java-1.8.0-openjdk-demo.x86_64 1.8.0.25-1.b17.el6 updates
  30. java-1.8.0-openjdk-devel.x86_64 1.8.0.25-1.b17.el6 updates
  31. java-1.8.0-openjdk-headless.x86_64 1.8.0.25-1.b17.el6 updates
  32. java-1.8.0-openjdk-javadoc.noarch 1.8.0.25-1.b17.el6 updates
  33. java-1.8.0-openjdk-src.x86_64 1.8.0.25-1.b17.el6 updates
  34. java_cup.x86_64 1:0.10k-5.el6 base
  35. java_cup-javadoc.x86_64 1:0.10k-5.el6 base
  36. java_cup-manual.x86_64 1:0.10k-5.el6 base
  37. javacc.x86_64 4.1-0.5.el6 base
  38. javacc-demo.x86_64 4.1-0.5.el6 base
  39. javacc-manual.x86_64 4.1-0.5.el6 base
  40. javassist.noarch 3.9.0-6.el6 base
  41. javassist-javadoc.noarch 3.9.0-6.el6 base
選擇jdk1.6安裝
  1. [root@E ~]# yum -y install java-1.6.0-openjdk*

其它版本請自己修改對應的版本號碼安裝 檢測是否安裝成功

  1. [root@E ~]# java -version
  2. java version "1.6.0_33"
  3. OpenJDK Runtime Environment (IcedTea6 1.13.5) (rhel-1.13.5.0.el6_6-x86_64)
  4. OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
安裝tomcat6 因為wdcp後台預設安裝的連接埠是8080,tomcat預設連接埠也是8080為了避免衝突請提前把wdcp後台連接埠改為其它連接埠(如:8089...) 可以到wdcp後台系統設定中手動修改:
  1. [root@E ~]# yum install tomcat6 tomcat6-webapps tomcat6-admin-webapps

安裝成功 啟動

  1. [root@E ~]# service tomcat6 start
  2. 其它命令:service tomcat6 {start|stop|restart|condrestart|try-restart|reload|force-reload|status|version}

啟動成功,訪問測試:http://ip:8080 能訪問即為安裝成功: 配置nginx和tomcat,使其不加連接埠號碼,直接通過網域名稱也能訪問 首先增加解析,使網域名稱指向到主機IP,本地可以直接改host實現 解析正常 不加8080連接埠訪問 添加8080連接埠訪問 接下來修改nginx和tomcat的配置使其不加連接埠號碼也能訪問到tomcat的webservice

  1. [root@E ~]# cd /www/wdlinux/nginx/conf/vhost/
  2. [root@E ~]# vi myweb.com.conf
  3. 添加如下內容
  4. server {
  5. listen 80;
  6. server_name www.myweb.com myweb.com;
  7. #root /www/web/master_myweb_com/public_html;
  8. index index.html index.jsp index.htm;
  9. error_page 400 /errpage/400.html;
  10. error_page 403 /errpage/403.html;
  11. error_page 404 /errpage/404.html;
  12. error_page 405 /errpage/405.html;
  13. location ~ \.jsp$ {
  14. proxy_pass http://127.0.0.1:8080;
  15. include naproxy.conf;
  16. }
  17. location / {
  18. try_files $uri @tomcat;
  19. }
  20. location @tomcat {
  21. proxy_pass http://127.0.0.1:8080;
  22. include naproxy.conf;
  23. }
  24. access_log /www/web_logs/myweb_com_access.log wwwlogs;
  25. error_log /www/web_logs/myweb_com_error.log;
  26. }

重新載入nginx設定檔或重啟nginx

  1. [root@E vhost]# service nginxd reload
  2. nginx: the configuration file /www/wdlinux/nginx/conf/nginx.conf syntax is ok
  3. nginx: configuration file /www/wdlinux/nginx/conf/nginx.conf test is successful

不加連接埠號碼訪問測試: 至此nginx已經成功將來自myweb.com網域名稱的請求代理到8080連接埠 如果需要配置多網域名稱的話,還需要修改tomcat虛擬機器主機設定檔 預設設定檔路徑:/etc/tomcat6/ 預設項目路徑:/var/lib/tomcat6/webapps/ tomcat預設指向/var/lib/tomcat6/webapps/ROOT目錄 建立新項目目錄,這裡直接複製ROOT項目,進行修改

  1. [root@E webapps]# pwd
  2. /var/lib/tomcat6/webapps
  3. [root@E webapps]# chown -R root myweb.com
  4. 修改許可權,使新項目許可權和預設項目許可權一致
  5. [root@E webapps]# chgrp -R tomcat myweb.com
  6. [root@E webapps]# ll
  7. 總用量 24
  8. drwxrwxr-x 5 root tomcat 4096 10月 30 22:06 examples
  9. drwxrwxr-x 5 root tomcat 4096 10月 30 22:06 host-manager
  10. drwxrwxr-x 5 root tomcat 4096 10月 30 22:06 manager
  11. drwxr-xr-x 3 root tomcat 4096 10月 30 22:48 myweb.com
  12. drwxrwxr-x 3 root tomcat 4096 10月 30 22:06 ROOT
  13. drwxrwxr-x 5 root tomcat 4096 10月 30 22:06 sample
  14. [root@E myweb.com]# cd myweb.com/
  15. [root@E myweb.com]# rm -f index.html
  16. [root@E myweb.com]# vi index.jsp
  17. 寫入:WebService is Tomcat
  18. 不要忘記刪除ROOT項目或者對它重命,否則新項目不生效
  19. [root@E webapps]# mv ROOT/ ROOT.BAK

修改tomcat虛擬機器主機配置

  1. [root@E myweb.com]# vi /etc/tomcat6/server.xml
  2. 在最下面<Host></Host>標籤後面添加如下內容
  3. <!--myweb.com host config-->
  4. <Host name="www.myweb.com" appBase="webapps"
  5. unpackWARs="true" autoDeploy="true"
  6. xmlValidation="false" xmlNamespaceAware="false">
  7. <Context path="/" reloadable="true" docBase="myweb.com"/>
  8. <Alias>myweb.com</Alias>
  9. <!-- SingleSignOn valve, share authentication between web applications
  10. Documentation at: /docs/config/valve.html -->
  11. <!--
  12. <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
  13. -->
  14. <!-- Access log processes all example.
  15. Documentation at: /docs/config/valve.html -->
  16. <!--
  17. <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
  18. prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
  19. -->
  20. </Host>

重啟tomcat,測試 [root@E myweb.com]# service tomcat6 restart success!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.