用wdcp官方提供的腳本安裝lnamp環境,安裝請參考:http://www.wdlinux.cn/bbs/thread-6292-1-1.html,本文主要講如何在LNAMP環境下安裝JDK+Tomcat6使同一台伺服器同時支援PHP和JAVA語言。伺服器系統及各軟體版本如下圖
[root@E ~]# uname -a
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
[root@E ~]# /www/wdlinux/nginx/sbin/nginx -v
nginx version: nginx/1.2.9v
nginx version: nginx/1.2.9 wdlinux/httpd-2.2.24/bin/httpd -v
Server version: Apache/2.2.24 (Unix)
Server built: Oct 30 2014 00:17:07
[ qa |grep mysql
mysql-libs-5.1.66-2.el6_3.x86_64
[root@E ~]# /www/wdlinux/php/bin/php -v
~]# /www/wdlinux/php/bin/php -v
not built with configuration 1.2.0, whereas running engine is API220090626,NTS
PHP 5.3.27 (cli) (built: Oct 30 2014 00:30:02)cliright (h Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
開始安裝jdk: 列出yum庫可用的jdk安裝包
[root@E ~]# yum -yum庫可用的jdk安裝包
[root@E ~]# yum -y list java plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.edu.cn
* extras: mirror.bit.edu.cncn
* extras: mirror.bit.edu.cncn
* mir updates: mirrors.neusoft.edu.cnbase | 3.7 kB 00:00extras | 3.3 kB 00:00rpmforge | 1.90B 00:0003003:0000303030303:000:00003:00:00003:003:00003:003:0003:003:000303:003:0030303:003) mary_db | 171 kB 00:00Available Packagesjava-1.5.0-gcj.x86_64 1.5.0.0-29.1.el6 base-1.5.0-29.1.el6 base-1.5.0-gj. java-1.5.0-gcj-javadoc.x86_64 1.5.0.0-29.1.el6 basejava-1.5.0-gcj-src.x86_64 1.5.0.0-29.1.0.0-29.1.0.05 openjdk.x86_64 1:1.6.0.33-1.13.5.0.el6_6 updatesjava-1.6.0-openjdk-demo.x86_64 1:1.6.0.33-1.openjdk-demo.x86_64 1:1.6.0.33-1.13.5.0.p. devel.x86_64 1:1.6.0.33-1.13.5.0.el6_6 updatesjava-1.6.0-openjdk-javadoc.x86_64 1:1.6.0.33-1.13.65.0.el 是p. src.x86_64 1:1.6.0.33-1.13.5.0.el6_6 updatesjava-1.7.0-openk.x86_64 1:1.7.0.71-2.5.3.jdk.x86_64 1:1.7.0.71-2.5.3.jdk.x86_64 1:1.7.0.71-2.5.3.jdk.x86_64 1:1.7.0.71-2.5.3.jdk.x86-dates x86_64 1:1.7.0.71-2.5.3.1.el6 updatesjava-1.7.0-openjdk-devel.x86_64 1:1.7.0.71-2.5.3.1.el6 updates. noarch 1:1.7.0.71-2.5.3.1.el6 updates
java-1.7.0-openjdk-src.x86_64 1:1.7.0.71-2.5.3.1.el6 updates
. .0.25-1.b17.el6 updatesjava-1.8.0-openjdk-demo.x86_64 1.8.0.25-1.b17.el6 updatesjava-1.8.80-openk-dep. .b17.el6 updatesjava-1.8.0-openjdk-headless.x86_64 1.8.0.25-1.b17.el6 updatesjava-1.8.0-openk-javadoc7.5. updatesjava-1.8.0-openjdk-src.x86_64 1.8.0.25-1.b17.el6 updates_cup.x86_64 1:0.10k-5.el6 java_cup.x86_64 1:0.10k-5.el6 java_cup.x86_64 1:0.10k-5。 5.el6 basejava_cup-manual.x86_64 1:0.10k-5.el6 basejavacc.x86_64 4.1-0.5.el6 值x86_64 4.1-0.5.el6 base
javassist.noarch 3.9.0-6.el6 base
javassist-javadoc.noarch 3.9.0-6.el6 base
. # yum -y install java-1.6.0-openjdk*
其它版本請自行修改對應的版本號安裝檢測是否安裝成功
[root@E ~]# java -version
java version "1.6.0_33"
OpenJDK Runtime Environment (IcedTea6 1.13.5) (rhel-1.13.5.0.el6_6-x86_64)
OpenJDK 64-Bit Server VM (build 23.2550 月安裝的連接埠是8080,tomcat預設埠也是8080為了避免衝突請提前把wdcp後台埠改為其它埠(如:8089...) 可以到wdcp後台系統設定手動修改:
[root@E ~]# yum install tomcat6 tomcat6-webapps tomcat6-admin-webapps
安裝成功啟動
[root@E ~]# service tomcat6 start
其它指令:service tomcat6 {start|stop|restart|condrestart|restart|condrestart-restart| reload|status|version}
啟動成功,存取測試:http://ip:8080 能存取即為安裝成功: 設定nginx和tomcat,使其不加連接埠號,直接透過網域也能存取先增加解析,讓網域名稱指向主機IP,本機可以直接改host實作解析正常不加8080埠存取新增8080埠存取接下來修改nginx和tomcat的設定使其不加埠號也能存取到tomcat的webservice
[root@ E ~]# cd /www/wdlinux/nginx/conf/vhost/
[root@E ~]# vi myweb.com.conf
加入以下內容
server {
listen 80; myweb.com myweb.com;
#root /www/web/master_myweb_com/public_html;
index index.html index.jsp index.htm;
error_page 400 /errpage/400.html; /403.html;
error_page 404 /errpage/404.html;
error_page 405 /errpage/405.html;
location ~ .jsp$ {
59.70380.70385;include naproxy.conf;
}
location / {
try_files $uri @tomcat;
}
location @tomcat {tomcat;
}
location @tomcat {pro
}
;}access_log /www/web_logs/myweb_com_access.log wwwlogs;error_log /www/web_logs/myweb_com_error.log;# service nginxd reload
nginx: the configuration file /www/wdlinux/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /www/wdlinux/nginx/confn succ加埠號碼存取測試: 至此nginx已經成功將來自myweb.com網域的請求代理到8080埠如果需要設定多網域的話,還需要修改tomcat虛擬主機設定檔預設設定檔路徑:/etc/tomcat6/ 預設專案路徑:/var/lib/tomcat6/webapps/ tomcat預設指向/var/lib/tomcat6/webapps/ROOT目錄建立新專案目錄,這裡直接複製ROOT專案,進行修改
[root@E webapps]# pwd
/ var/lib/tomcat6/webapps
[root@E webapps]# chown -R root myweb.com
修改權限,使新專案權限和預設專案權限一致
[root@E webapps]# chgrp -R myweb.com
[root@E webapps]# ll
總用量24
drwxrwxr-x 5 root tomcat 4096 10月30 22:06 examples20 月 30 月 30 月 22:06 examples 6 host -manager
drwxrwxr-x 5 root tomcat 4096 10月30 22:06 manager
drwxr-xr-x 3 root tomcat 4096 10月30 22:48 webp. 10月30 22:06 ROOT
drwxrwxr-x 5 root tomcat 4096 10月30 22:06 sample
[root@E myweb.com]# cd myweb.com/
[root@E myweb.com]# cd myweb.com/
[root@E myweb.com]# cd myweb.com/
。 index.html
[root@E myweb.com]# vi index.jsp
寫入:WebService is Tomcat
不要忘記刪除ROOT專案或對它重命,否則新專案不生效
[root@root@E webapps]# mv ROOT/ ROOT.BAK
修改tomcat虛擬主機設定
[root@E myweb.com]# vi /etc/tomcat6/server.xml
在最下面
unpackWARs="true" autoDeploy="true" xmlValidation ="false" xmlNamespaceAware="false"> myweb.com myweb.com Documentation at: /docs/config/valve.html -->