真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

2.0Tonmcat高級(jí)配置和jDK的安裝配置-創(chuàng)新互聯(lián)

一、安裝JDK

目前成都創(chuàng)新互聯(lián)已為數(shù)千家的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬空間、網(wǎng)站托管運(yùn)營、企業(yè)網(wǎng)站設(shè)計(jì)、隴西網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。

1、下載

wget http://download.oracle.com/otn-pub/java/jdk/8u65-b17/jdk-8u65-linux-x64.tar.gz

2、解壓和安裝

[root@www src]# tar zxf jdk-8u65-linux-x64.tar.gz
[root@www src]# mv jdk1.8.0_65 /usr/local/

3、設(shè)置環(huán)境變量

[root@www src]# vim /etc/profile.d/java.sh

JAVA_HOME=/usr/local/jdk1.8.0_65
JAVA_BIN=/usr/local/jdk1.8.0_65/bin
JRE_HOME=/usr/local/jdk1.8.0_65/jre
PATH=$PATH:/usr/local/jdk1.8.0_65/bin:/usr/local/jdk1.8.0_65/jre/bin
CLASSPATH=/usr/local/jdk1.8.0_65/jre/lib:/usr/local/jdk1.8.0_65/lib:/usr/local/jdk1.8.0_65/jre/lib/charsets
.jar

4、初始化

[root@www src]# . /etc/profile.d/java.sh   //和source一樣
[root@www src]# source /etc/profile.d/java.sh

[root@www src]# which java
/usr/local/jdk1.8.0_65/bin/java

[root@www jdk1.8.0_65]# export PATH JAVA_HOME JAVA_BIN JRE_HOME CALSSPATH

5、查看版本

[root@www src]# java -version
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)

二、安裝Tomcat

1、下載

[root@www src]# wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.0.30/bin/apache-tomcat-8.0.30.tar.gz

2、解壓和安裝

[root@www src]# tar zxf apache-tomcat-8.0.30.tar.gz

[root@www src]# mv apache-tomcat-8.0.30 /usr/local/tomcat
[root@www src]# ls /usr/local/tomcat/
bin  conf  lib  LICENSE  logs  NOTICE  RELEASE-NOTES  RUNNING.txt  temp  webapps  work

3、拷貝啟動(dòng)腳本

[root@www src]# cd /usr/local/tomcat/
[root@www tomcat]# cp -v bin/catalina.sh /etc/init.d/tomcat
`bin/catalina.sh' -> `/etc/init.d/tomcat'

4、設(shè)置開機(jī)啟動(dòng)

[root@www tomcat]# chmod 755 /etc/init.d/tomcat
[root@www tomcat]# chkconfig --add tomcat
service tomcat does not support chkconfig   //服務(wù)不支持

解決:

[root@www tomcat]# vim /etc/init.d/tomcat    //在開頭加入以下內(nèi)容

#!/bin/sh
# chkconfig: 2345 63 37
# description: tomcat server init script
# Source Function Library
. /etc/init.d/functions
JAVA_HOME=/usr/local/jdk1.8.0_65
CATALINA_HOME=/usr/local/tomcat

[root@www tomcat]# chkconfig --add tomcat
[root@www tomcat]# chkconfig tomcat on

5、啟動(dòng)Tomcat

[root@www jdk1.8.0_65]# /etc/init.d/tomcat start
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/local/jdk1.8.0_65/jre
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.

查看tomcat進(jìn)程
[root@www ~]# ps aux |grep tomcat
root       3835  2.1  7.8 2722304 78704 pts/1   Sl   02:26   0:05 /usr/local/jdk1.8.0_65/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat/endorsed -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start
root       3867  0.0  0.0 103248   884 pts/1    S+   02:30   0:00 grep tomcat

[root@www ~]# /etc/init.d/tomcat stop

[root@www ~]# /etc/init.d/tomcat start

6、訪問測(cè)試

在瀏覽器輸入http://192.168.1.21:8080

2.0Tonmcat高級(jí)配置和jDK的安裝配置

三、Tomcat的配置和優(yōu)化

1、修改監(jiān)聽端口

(1)停止之前安裝nginx的進(jìn)程,避免80端口被占用

[root@www ~]# /etc/init.d/nginx stop
Stopping Nginx:                                            [  OK  ]
[root@www ~]# chkconfig nginx off

(2)修改tomcat監(jiān)聽端口為80

[root@www ~]# cd /usr/local/tomcat/conf/
[root@www conf]# ls
Catalina         catalina.properties  logging.properties  tomcat-users.xml  web.xml
catalina.policy  context.xml          server.xml          tomcat-users.xsd

[root@www conf]# vim server.xml

找到69行

69    

修改為

69    

(3)重啟tomcat

[root@www conf]# /etc/init.d/tomcat stop

[root@www conf]# /etc/init.d/tomcat start

(4)查看監(jiān)聽端口

[root@www conf]# netstat -nlp | grep java
tcp        0      0 :::80                       :::*                        LISTEN      4673/java
tcp        0      0 ::ffff:127.0.0.1:8005       :::*                        LISTEN      4673/java
tcp        0      0 :::8009                     :::*                        LISTEN      4673/java

訪問測(cè)試http://192.168.1.21/

2、虛擬主機(jī)配置

tomcat的默認(rèn)網(wǎng)站根目錄是/usr/local/tomcat/webapps/ROOT/

(1)增加虛擬目錄配置

[root@www conf]# vim server.xml 

                 unpackWARs="true" autoDeploy="true">

       
       

       
                       prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t "%r" %s %b" />
            //虛擬主機(jī)配置
     

path="/xuni" --虛擬目錄

docBase="/data/tomcatweb"  --實(shí)際目錄

(2)創(chuàng)建虛擬目錄

[root@www ~]# mkdir -p /data/tomcatweb

創(chuàng)建測(cè)試頁面

[root@www ~]# vim /data/tomcatweb/111.jsp


    Now time is: <%=new java.util.Date()%>

[root@www ~]# /etc/init.d/tomcat stop
[root@www ~]# /etc/init.d/tomcat start

[root@www ~]# ps aux |grep tomcat
root       5872 34.7  7.6 2722304 76924 pts/1   Sl   04:46   0:04 /usr/local/jdk1.8.0_65/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat/endorsed -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start
root       5896  0.0  0.0 103248   884 pts/1    S+   04:46   0:00 grep tomcat
[root@www ~]# netstat -nlp |grep java
tcp        0      0 :::80                       :::*                        LISTEN      5872/java
tcp        0      0 ::ffff:127.0.0.1:8005       :::*                        LISTEN      5872/java
tcp        0      0 :::8009                     :::*                        LISTEN      5872/java 

訪問測(cè)試:

[root@www ~]# curl http://192.168.1.21/xuni/111.jsp


    Now time is: Mon Dec 21 04:48:19 CST 2015

[root@www ~]# curl -x192.168.1.21:80 localhost/xuni/111.jsp


    Now time is: Mon Dec 21 04:48:56 CST 2015

四、限制主機(jī)訪問Tomcat

1、修改server.xml

[root@www conf]# vim server.xml 

                 unpackWARs="true" autoDeploy="true">

                      prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t "%r" %s %b" />
       
            //允許192.168.1.0網(wǎng)段訪問,拒絕192.168.1.218訪問
                        allow="192.168.1.*" deny="192.168.1.218"/>

     

2、訪問測(cè)試

[root@www ~]# curl http://192.168.1.21 -I
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Date: Sun, 20 Dec 2015 21:37:32 GMT
在192.168.1.218下訪問

[root@sh ~]# curl http://192.168.1.21 -I
HTTP/1.1 403 Forbidden
Server: Apache-Coyote/1.1
Transfer-Encoding: chunked
Date: Sun, 20 Dec 2015 21:38:01 GMT

2.0Tonmcat高級(jí)配置和jDK的安裝配置

五、配置用戶WEB網(wǎng)站

1、創(chuàng)建用戶及頁面

[root@www ~]# useradd admin1
[root@www ~]# useradd admin2

[root@www ~]# su - admin1
[admin1@www ~]$ pwd
/home/admin1
[admin1@www ~]$ mkdir public_html
[admin1@www ~]$ echo "admin1" >public_html/index.html
[admin1@www ~]$ ll
total 4
drwxrwxr-x 2 admin1 admin1 4096 Dec 21 05:54 public_html
[admin1@www ~]$ chmod 711 /home/admin1
[admin1@www ~]$ ll /home/admin1/public_html/index.html
-rw-rw-r-- 1 admin1 admin1 7 Dec 21 05:54 /home/admin1/public_html/index.html

2、配置server.xml

[root@www conf]# vim server.xml 

在host中增加以下內(nèi)容

                       directoryName="public_html" homeBase="/home"
                userClass="org.apache.catalina.startup.PasswdUserDatabase"/>

3、訪問用戶admin1的網(wǎng)頁,在瀏覽器輸入http://192.168.1.21/~admin1

2.0Tonmcat高級(jí)配置和jDK的安裝配置

六、配置Tomcat服務(wù)器支持CGI

CGI是通用網(wǎng)關(guān)接口功能

1、安裝perl軟件

[root@www ~]# yum -y install perl

2、編輯/usr/local/tomcat/conf/web.xml文件

[root@www ~]# vim /usr/local/tomcat/conf/web.xml

369    
 370         cgi
 371         org.apache.catalina.servlets.CGIServlet
 372        
 373           debug
 374           0
 375        

 376        
 377           cgiPathPrefix
 378           WEB-INF/cgi
 379        

 380          5
 381    

417    
 418         cgi
 419         /cgi-bin/*
 420    

3、編輯/usr/local/tomcat/conf/context.xml文件,增加privileged配置



    WEB-INF/web.xml
    ${catalina.base}/conf/web.xml

4、創(chuàng)建CGI測(cè)試頁面

[root@www ~]# mkdir /usr/local/tomcat/webapps/ROOT/WEB-INF/cgi/test.cgi 

#!/usr/bin/perl
print "Content-type:text/plain\n\n";
print "Hello cgi\n";
#
[root@www ~]# chmod 711 usr/local/tomcat/webapps/ROOT/WEB-INF/cgi/test.cgi

5、測(cè)試cgi

[root@www ~]# /etc/init.d/tomcat stop
[root@www ~]# /etc/init.d/tomcat start

2.0Tonmcat高級(jí)配置和jDK的安裝配置

七、配置管理Tomcat服務(wù)器

1、配置/usr/local/tomcat/conf/tomcat-users.xml文件,可以配置tomcat管理用戶,定義角色及角色中包含的用戶和密碼,修改后內(nèi)容如下

[root@www ~]# vim /usr/local/tomcat/conf/tomcat-users.xml 


              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
              version="1.0">


//用戶為kiven,密碼為kiven,屬于角色manager-gui

2、訪問測(cè)試,打開tomcat首頁,點(diǎn)擊頁面右上角【Manager App】

2.0Tonmcat高級(jí)配置和jDK的安裝配置

2.0Tonmcat高級(jí)配置和jDK的安裝配置

訪問【Server Status】

2.0Tonmcat高級(jí)配置和jDK的安裝配置

3、配置Host Manager,可以管理tomcat虛擬主機(jī)

(1)編輯/usr/local/tomcat/webapps/manager/WEB-INF/web.xml文件

在行添加以下內(nèi)容


   
        The role that is required to access to the Host Manager pages
   

    admin-gui

(2)編輯/usr/local/tomcat/conf/tomcat-users.xml文件


              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
              version="1.0">






(3)訪問Host manager

2.0Tonmcat高級(jí)配置和jDK的安裝配置

八、配置https網(wǎng)站

1、生成服務(wù)器端證書文件,證書有效期為36500天

[root@www ~]# keytool -genkey -alias tomcat -keyalg RSA -keystore /etc/tomcat.keystore -validity 36500
Enter keystore password:       //6位密鑰庫口令
Re-enter new password:
What is your first and last name?   //名字,可以是服務(wù)器網(wǎng)站名稱
  [Unknown]:  hm
What is the name of your organizational unit?  //組織單位名稱
  [Unknown]:  it
What is the name of your organization?   //組織名稱
  [Unknown]:  redhat
What is the name of your City or Locality?  //城市
  [Unknown]:  shanghai
What is the name of your State or Province?  //省市
  [Unknown]:  shanghai
What is the two-letter country code for this unit? //國家或地區(qū)代碼
  [Unknown]:  CN
Is CN=hm, OU=it, O=redhat, L=shanghai, ST=shanghai, C=CN correct?
  [no]:  y

Enter key password for
    (RETURN if same as keystore password):

2、配置/usr/local/tomcat/conf/server.xml文件

......

                  connectionTimeout="20000"
               redirectPort="8443" />

                   maxThreads="150" scheme="https" secure="true"
                clientAuth="false" sslProtocol="TLS" keystoreFile="/etc/tomcat.keystore"
                keystorePass="741616710"/>
   

 

3、配置/usr/local/tomcat/conf/web.xml文件,在行上面增加以下內(nèi)容

  
       
        SSL
        /*
       

       
        CONFIDENTIAL
       

   

4、重啟tomcat服務(wù)

[root@www ~]# /etc/init.d/tomcat stop
[root@www ~]# /etc/init.d/tomcat start
[root@www ~]# netstat -anlp |grep 8443
tcp        0      0 :::8443                     :::*                        LISTEN      8372/java   

5、訪問https網(wǎng)站2.0Tonmcat高級(jí)配置和jDK的安裝配置

6、修改https監(jiān)聽端口為默認(rèn)的端口443 

2.0Tonmcat高級(jí)配置和jDK的安裝配置


標(biāo)題名稱:2.0Tonmcat高級(jí)配置和jDK的安裝配置-創(chuàng)新互聯(lián)
當(dāng)前地址:http://weahome.cn/article/ddojjh.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部