tomcat 和 jdkhtml
安裝前準備java
輸入systemctl status firewalld
命令查看當前防火牆的狀態。linux
systemctl stop firewalld
。
systemctl disable firewalld
。
getenforce
命令查看當前SELinux的狀態。若是顯示Disabled
,則SELinux爲關閉狀態。若是顯示Enforcing
,則SELinux爲開啓狀態,運行以下命令關閉SELinux:
setenforce 0
。
vi /etc/selinux/config
編輯SELinux配置文件。回車後,把光標移動到SELINUX=enforcing
這一行,按下i鍵進入編輯模式,修改成SELINUX=disabled
,按Esc
鍵,而後輸入:wq
並回車以保存並關閉SELinux配置文件。
useradd www
mkdir -p /data/wwwroot/default
echo Tomcat test > /data/wwwroot/default/index.jsp chown -R www.www /data/wwwroot
tar xzf apache-tomcat-8.5.34.tar.gz
mv apache-tomcat-8.5.34 /usr/local/tomcat/ chown -R www.www /usr/local/tomcat/
cd /usr/local/tomcat/conf/
。mv server.xml server.xml_bk
。vi server.xml
。i
鍵進入編輯模式。<?xml version="1.0" encoding="UTF-8"?> <Server port="8006" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/> <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/> <Listener className="org.apache.catalina.core.AprLifecycleListener"/> <GlobalNamingResources> <Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml"/> </GlobalNamingResources> <Service name="Catalina"> <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" maxThreads="1000" minSpareThreads="20" acceptCount="1000" maxHttpHeaderSize="65536" debug="0" disableUploadTimeout="true" useBodyEncodingForURI="true" enableLookups="false" URIEncoding="UTF-8"/> <Engine name="Catalina" defaultHost="localhost"> <Realm className="org.apache.catalina.realm.LockOutRealm"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <Host name="localhost" appBase="/data/wwwroot/default" unpackWARs="true" autoDeploy="true"> <Context path="" docBase="/data/wwwroot/default" debug="0" reloadable="false" crossContext="true"/> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> </Engine> </Service> </Server>
Esc
鍵退出編輯模式,輸入:wq
保存並退出編輯。
vi /usr/local/tomcat/bin/setenv.sh
, 建立/usr/local/tomcat/bin/setenv.sh。i
鍵進入編輯模式。JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms256m -Xmx496m -Dfile.encoding=UTF-8'
Esc
鍵退出編輯模式,輸入:wq
保存並退出文件。wget https://github.com/lj2007331/oneinstack/raw/master/init.d/Tomcat-init
mv Tomcat-init /etc/init.d/tomcat
chmod +x /etc/init.d/tomcat
sed -i 's@^export JAVA_HOME=.*@export JAVA_HOME=/usr/java/jdk1.8.0_191@' /etc/init.d/tomcat
chkconfig --add tomcat chkconfig tomcat on
service tomcat start
http://公網IP:8080
進行訪問。出現下圖所示頁面時表示安裝成功。
按如下步驟安裝 JDK。git
mkdir /usr/java
chmod +x jdk-8u191-linux-x64.tar.gz tar xzf jdk-8u191-linux-x64.tar.gz -C /usr/java
vi /etc/profile
。i
鍵進入編輯模式。# set java environment export JAVA_HOME=/usr/java/jdk1.8.0_191 export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib export PATH=$JAVA_HOME/bin:$PATH
Esc
鍵退出編輯模式,輸入:wq
保存並關閉文件。source /etc/profile
。java -version
命令,顯示JDK版本信息時,表示 JDK 已經安裝成功。