安装jdk和tomcat
jdk1.7.0_13(系列)下载url
我这里用的最新的jdk.
- 去官网下载即可
cd /usr/local/src/
tar xf jdk-8u162-linux-x64.tar.gz -C /usr/local/
ln -s /usr/local/jdk1.8.0_162 /usr/local/jdk
tar xf apache-tomcat-8.5.29.tar.gz -C /usr/local/
ln -s /usr/local/apache-tomcat-8.5.29 /usr/local/tomcat- 查看目录/usr/local
[root@n1 local]# ls -ld jdk* *tomcat*
drwxr-xr-x 8 10 143 255 Dec 20 13:27 jdk1.8.0_162
lrwxrwxrwx 1 root root 23 Mar 14 09:15 jdk -> /usr/local/jdk1.8.0_162
drwxr-xr-x 9 root root 160 Mar 14 09:14 apache-tomcat-8.5.29
lrwxrwxrwx 1 root root 31 Mar 14 09:15 tomcat -> /usr/local/apache-tomcat-8.5.29
- 添加path
sed -i.ori '$a export JAVA_HOME=/usr/local/jdk\nexport PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH\nexport CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar' /etc/profile
echo 'export TOMCAT_HOME=/usr/local/tomcat'>>/etc/profilesource /etc/profile
即
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar
export TOMCAT_HOME=/usr/local/tomcat
[root@n1 ~]# java -version
java version "1.8.0_162"
Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)- 启动tomcat
[root@n1 tomcat]# /usr/local/tomcat/bin/catalina.sh 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/jdk
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@n1 tomcat]# netstat -ntulp|grep java
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1277/java
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 1277/java
tcp 0 0 0.0.0.0:8009 0.0.0.0:* LISTEN 1277/java
一键jdk+tomcat部署脚本(jdk和tomcat放到/usr/local/src)
cd /usr/local/src/
tar xf jdk-8u162-linux-x64.tar.gz -C /usr/local/
ln -s /usr/local/jdk1.8.0_162 /usr/local/jdk
tar xf apache-tomcat-8.5.29.tar.gz -C /usr/local/
ln -s /usr/local/apache-tomcat-8.5.29 /usr/local/tomcatsed -i.ori '$a export JAVA_HOME=/usr/local/jdk\nexport PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH\nexport CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar' /etc/profile
echo 'export TOMCAT_HOME=/usr/local/tomcat'>>/etc/profile
source /etc/profile/usr/local/tomcat/bin/catalina.sh start
sleep 3
ls -ld /usr/local/jdk* /usr/local/*tomcat*
java --version
netstat -ntulp|grep java
curl -I 192.168.14.11:8080
部署app,以java的开源论坛jforum为例
抽时间也可以部署下jpress,国人写的.部署方法
- 默认部署会报错,导致安装失败, 提前解决下
本质上是因为sql问题,将每句的TYPE=InnoDB去掉即可.
Query being executed when exception was thrown: CREATE TABLE jforum_banlist ( banlist_id INT NOT NULL auto_increment, user_id INT, banlist_ip varchar(15), banlist_email varchar(255), PRIMARY KEY (banlist_id), INDEX idx_user (user_id), INDEX (banlist_ip), INDEX (banlist_email)) TYPE=InnoDB
CREATE TABLE jforum_banlist ( banlist_id INT NOT NULL auto_increment, user_id INT, banlist_ip varchar(15), banlist_email varchar(255), PRIMARY KEY (banlist_id), INDEX idx_user (user_id), INDEX (banlist_ip), INDEX (banlist_email)) TYPE=InnoDB"
- 修改好后,压缩,上传,解压.
tar xf jforum-2.1.9.tar.gz -C /usr/local/tomcat/webapps/
cd /usr/local/tomcat/webapps/
mv jforum-2.1.9 jforum/usr/local/tomcat/bin/catalina.sh stop
/usr/local/tomcat/bin/catalina.sh start
- 部署mysql
docker run \
-p 3306:3306 \
-v /data/mysql:/var/lib/mysql \
-v /etc/localtime:/etc/localtime \
--name mysql5 \
--restart=always \
-e MYSQL_ROOT_PASSWORD=123456 \
-d mysql:5.6.23 --character-set-server=utf8 --collation-server=utf8_general_ci- 建库
mysql> create database jforum;
- 安装jforum
访问http://192.168.14.11:8080/jforum/install.jsp
自此部署form论坛完成.
自此体验了一把jdk+tomcat的一个app的部署. 后面会整理下tomcat这个动态应用的基础知识和优化.