您好,登錄后才能下訂單哦!
[root@localhost ~]# mount.cifs //192.168.100.10/tomcat /mnt //將存有tomcat的工具掛載到mnt目錄
Password for root@//192.168.100.10/tomcat:
[root@localhost ~]# cd /mnt //進入mnt目錄
[root@localhost mnt]# ls //查看是否成功掛載
12D18CFCD6599AFF0445766ACC4CA231C5025773.torrent apache-tomcat-9.0.16.tar.gz
apache-jmeter-5.1 jdk-8u201-linux-x64.rpm
apache-jmeter-5.1.zip tomcat優化壓測.jmx
[root@localhost mnt]# rpm -ivh jdk-8u201-linux-x64.rpm //安裝jdk包
警告:jdk-8u201-linux-x64.rpm: 頭V3 RSA/SHA256 Signature, 密鑰 ID ec551f03: NOKEY
準備中... ################################# [100%]
正在升級/安裝...
1:jdk1.8-2000:1.8.0_201-fcs ################################# [100%]
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
[root@localhost mnt]# cd /usr/java/ //進入Java安裝目錄
[root@localhost java]# ls
default jdk1.8.0_201-amd64 latest
[root@localhost java]# cd jdk1.8.0_201-amd64/ //進入jdk目錄
[root@localhost jdk1.8.0_201-amd64]# ls
bin jre README.html THIRDPARTYLICENSEREADME.txt
COPYRIGHT lib release
include LICENSE src.zip
javafx-src.zip man THIRDPARTYLICENSEREADME-JAVAFX.txt
[root@localhost jdk1.8.0_201-amd64]# pwd //查看當前位置
/usr/java/jdk1.8.0_201-amd64 //復制此條目
[root@localhost jdk1.8.0_201-amd64]# vim /etc/profile //編輯profile文件進行參數更新
export JAVA_HOME=/usr/java/jdk1.8.0_201-amd64 //聲明變量位置
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar //聲明CLASS變量
export PATH=$JAVA_HOME/bin:$PATH //聲明環境變量
:qw
[root@localhost jdk1.8.0_201-amd64]# source /etc/profile //執行profile文件
[root@localhost jdk1.8.0_201-amd64]# java -version //查看Java版本,測試Java是否安裝成功
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
root@localhost jdk1.8.0_201-amd64]# cd /mnt
[root@localhost mnt]# ls
12D18CFCD6599AFF0445766ACC4CA231C5025773.torrent apache-tomcat-9.0.16.tar.gz
apache-jmeter-5.1 jdk-8u201-linux-x64.rpm
apache-jmeter-5.1.zip tomcat優化壓測.jmx
[root@localhost mnt]# tar zxvf apache-tomcat-9.0.16.tar.gz -C /usr/local/ //解壓tomcat文件到/usr/local目錄
[root@localhost mnt]# cd /usr/local/
[root@localhost local]# ls
apache-tomcat-9.0.16 bin etc games include lib lib64 libexec sbin share src
[root@localhost local]# mv apache-tomcat-9.0.16/ tomcat //將文件更名
[root@localhost local]# cd tomcat/ //進入tomcat目錄
[root@localhost tomcat]# ls
bin conf lib logs README.md RUNNING.txt webapps
BUILDING.txt CONTRIBUTING.md LICENSE NOTICE RELEASE-NOTES temp work
[root@localhost tomcat]# cd bin //進入命令存放目錄
[root@localhost bin]# ls
bootstrap.jar commons-daemon-native.tar.gz makebase.sh tomcat-juli.jar
catalina.bat configtest.bat setclasspath.bat tomcat-native.tar.gz
catalina.sh configtest.sh setclasspath.sh tool-wrapper.bat
catalina-tasks.xml daemon.sh shutdown.bat tool-wrapper.sh
ciphers.bat digest.bat shutdown.sh version.bat
ciphers.sh digest.sh startup.bat version.sh
commons-daemon.jar makebase.bat startup.sh
[root@localhost bin]# ln -s /usr/local/tomcat/bin/startup.sh /usr/bin/ //將軟件啟動腳本建立軟連接到系統命令目錄下
[root@localhost bin]# ln -s /usr/local/tomcat/bin/shutdown.sh /usr/bin/ //將關閉軟件腳本建立軟連接到系統命令目錄下
[root@localhost bin]# systemctl stop firewalld.service //關閉防火墻
[root@localhost bin]# setenforce 0 //關閉增強性安全功能
[root@localhost bin]# startup.sh //使用命令啟動tomcat服務(可以使用TAB鍵補全哦)
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.8.0_201-amd64
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@localhost bin]# netstat -ntap | grep 8080 //使用命令查看端口是否開啟
tcp6 0 0 :::8080 :::* LISTEN 3137/java
[root@localhost bin]# shutdown.sh //關閉軟件
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.8.0_201-amd64
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.j
[root@localhost security]# cd /usr/java/jdk1.8.0_201-amd64/jre/lib/security/ //進入Java目錄
[root@localhost security]# vim java.security //修改jdk參數,優化tomcat啟動速度
...//省略部分內容...
# In addition, if "file:/dev/random" or "file:/dev/urandom" is
# specified, the "NativePRNG" implementation will be more preferred than
# SHA1PRNG in the Sun provider.
#
securerandom.source=file:/dev/urandom //random更改為urandom優化tomcat啟動速度
...//省略部分內容...
:wq
[root@localhost security]# startup.sh //再次啟動,啟動速度加快
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.8.0_201-amd64
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@localhost security]# yum install -y bind //安裝DNSfuwu
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
...//省略部分內容...
Installed:
bind.x86_64 32:9.11.4-9.P2.el7
...//省略部分內容...
Complete!
[root@localhost conf]# vim /etc/named.conf //編輯修改DNS服務主配置文件
...//省略部分內容...
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { any; };
...//省略部分內容...
:wq
[root@localhost conf]# vim /etc/named.rfc1912.zones //編輯修改DNS服務區域配置文件
...//省略部分內容...
zone "kgc.com" IN {
type master;
file "kgc.com.zone";
allow-update { none; };
};
...//省略部分內容...
:wq
[root@localhost conf]# cd /var/named/ //進入DNS服務區域數據文件存放目錄
[root@localhost named]# cp -p named.localhost kgc.com.zone //復制區域數據文件模板
[root@localhost named]# vim kgc.com.zone //編輯修改DNS服務區域數據配置文件
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
www IN A 192.168.144.133
:wq
[root@localhost named]# systemctl start named //啟動DNS服務
[root@localhost conf]# vim /etc/named.rfc1912.zones //編輯DNS服務區域配置文件
...//省略部分內容...
zone "kgc.com" IN {
type master;
file "kgc.com.zone";
allow-update { none; };
};
zone "accp.com" IN {
type master;
file "accp.com.zone";
allow-update { none; };
};
...//省略部分內容...
:wq
[root@localhost conf]# cd /var/named/ //進入區域數據文件目錄
[root@localhost named]# cp -p kgc.com.zone accp.com.zone //復制DNS服務區域數據配置文件
[root@localhost named]# systemctl restart named //重啟DNS服務
[root@localhost named]# cd ~
[root@localhost ~]# cd /usr/local/tomcat/ //進入tomcat目錄文件
[root@localhost tomcat]# ls
bin conf lib logs README.md RUNNING.txt webapps
BUILDING.txt CONTRIBUTING.md LICENSE NOTICE RELEASE-NOTES temp work
[root@localhost tomcat]# cd webapps/ //進入服務網頁站點
[root@localhost webapps]# ls
docs examples host-manager manager ROOT
[root@localhost webapps]# mkdir kgc //創建目錄
[root@localhost webapps]# echo "this is kgc web" > kgc/index.jsp //編輯主頁文件
[root@localhost webapps]# mkdir accp //創建目錄
[root@localhost webapps]# echo "this is accp web" > accp/index.jsp //編輯主頁文件
[root@localhost webapps]# tree accp/ kgc/ //使用命令以樹形結構查看目錄
accp/
└── index.jsp
kgc/
└── index.jsp
[root@localhost webapps]# cd ../conf/ //進入tomcat配置文件存放目錄
[root@localhost conf]# ls
Catalina catalina.properties jaspic-providers.xml logging.properties tomcat-users.xml web.xml
catalina.policy context.xml jaspic-providers.xsd server.xml tomcat-users.xsd
[root@localhost conf]# vim server.xml //編輯配置文件,編輯虛擬主機配置
...//省略部分內容...
<Host name="www.accp.com" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Context docBase="/usr/local/tomcat/webapps/accp" path="" reloadable="true"/>
</Host>
<Host name="www.kgc.com" appBase="webapps" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
<Context docBase="/usr/local/tomcat/webapps/kgc" path="" reloadable="true"/>
</Host>
...//省略部分內容...
:wq
[root@localhost conf]# shutdown.sh //關閉tomcat服務
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.8.0_201-amd64
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@localhost conf]# startup.sh //啟動tomcat服務
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.8.0_201-amd64
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
【noCompressionUserAgents="gozilla, traviata"】對于以下的瀏覽器,不啟用壓縮
[root@localhost conf]# vim server.xml //編輯tomcat配置文件
...//省略部分內容...
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
minSpareThreads="50"
enableLookups="false" //添加優化條目
disableUploadTimeout="true"
acceptCount="300"
maxThreads="500"
processorCache="500"
URIEncoding="UTF-8"
compression="on"
compressionMinSize="2048"
compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain,image/gif,image /jpg,image/png"/>
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
...//省略部分內容...
:wq
[root@localhost conf]# shutdown.sh //停止服務
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.8.0_201-amd64
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@localhost conf]# startup.sh //啟動服務
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.8.0_201-amd64
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。