码迷,mamicode.com
首页 > 其他好文 > 详细

Centos7部署Tomcat项目

时间:2017-02-17 21:45:48      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:warning   wan   erp   user   stat   tomcat   png   mnt   send   

tomcat基于java环境运行,需要安装jdk和tomcat。

1、上传安装包

sunny@DOCKER:~$ sudo mkdir /root/software 创建本地映射目录

root@DOCKER:~/software# ll 使用root账号,上传安装包文件

-rw-r--r-- 1 root root 8900822 6月 23 2016 apache-tomcat-7.0.68.tar.gz

-rw-r--r-- 1 root root 153512879 6月 23 2016 jdk-7u79-linux-x64.tar.gz

sunny@DOCKER:~$ docker run -it -v /root/software:/mnt/software ddb0d /bin/bash

[root@e54e4a205a2c /]#

 

2、安装jdk

[root@e54e4a205a2c software]# tar -xf jdk-7u79-linux-x64.tar.gz

[root@e54e4a205a2c software]# mv jdk1.7.0_79 /home/

[root@e54e4a205a2c home]# vi /etc/profile 末尾增加以下内容

JAVA_HOME=/home/jdk1.7.0_79

export JAVA_HOME

PATH=$JAVA_HOME/bin:$PATH

export PATH

echo $JAVA_HOME

[root@e54e4a205a2c home]# source /etc/profile

/home/jdk1.7.0_79

[root@e54e4a205a2c home]# java -version

java version "1.7.0_79"

 

3、tomcat安装

[root@e54e4a205a2c home]# cd /mnt/software

[root@e54e4a205a2c software]# tar -xf apache-tomcat-7.0.68.tar.gz

[root@e54e4a205a2c software]# mv apache-tomcat-7.0.68 /home/tomcat

[root@e54e4a205a2c software]# cd /home

[root@e54e4a205a2c home]# ll

drwxr-xr-x 8 10 143 4096 Apr 10 2015 jdk1.7.0_79

drwxr-xr-x 9 root root 4096 Feb 17 06:47 tomcat

[root@e54e4a205a2c home]# exit

 

4、创建tomcat镜像

sunny@DOCKER:~$ docker commit e54e centos/centos7-tomcat:20170217

2ab2c6930f249eab7af4c47d3bd6df433ef3d540c16c7fd9f33f7f7220dc9524

sunny@DOCKER:~$ docker images

REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE

centos/centos7-tomcat 20170217 2ab2c6930f24 16 seconds ago 585.4 MB

 

5、启动新容器

sunny@DOCKER:~$ docker run -itd -p 10023:22 -p 10024:8080 centos/centos7-tomcat:20170217

5e1c5f2d9184ebeaa70d111c546f8947479533356541cf8dd7ffe51277585397

sunny@DOCKER:~$ docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

5e1c5f2d9184 centos/centos7-tomcat:20170217 "/bin/bash" 4 seconds ago Up 3 seconds 0.0.0.0:10023->22/tcp, 0.0.0.0:10024->8080/tcp

sunny@DOCKER:~$ docker exec -it 5e1c /bin/bash

[root@5e1c5f2d9184 bin]# passwd

Changing password for user root.

New password: ceshi123

[root@5e1c5f2d9184 /]# cd /home/tomcat/bin/

[root@5e1c5f2d9184 bin]# source /etc/profile

[root@5e1c5f2d9184 bin]# java -version

[root@5e1c5f2d9184 bin]# /usr/sbin/sshd -D &

[root@5e1c5f2d9184 bin]# ./startup.sh

[root@5e1c5f2d9184 bin]# netstat -lnp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 34/sshd

tcp6 0 0 :::22 :::* LISTEN 34/sshd

tcp6 0 0 127.0.0.1:8005 :::* LISTEN 81/java

tcp6 0 0 :::8009 :::* LISTEN 81/java

tcp6 0 0 :::8080 :::* LISTEN 81/java

 

6、测试

[root@maven www]# ssh 192.168.1.185 -p 10023

The authenticity of host ‘[192.168.1.185]:10023 ([192.168.1.185]:10023)‘ can‘t be established.

RSA key fingerprint is 00:3b:ee:8f:19:1e:43:6a:c0:61:80:b5:83:2e:9b:5f.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added ‘[192.168.1.185]:10023‘ (RSA) to the list of known hosts.

root@192.168.1.185‘s password:

/home/jdk1.7.0_79

[root@5e1c5f2d9184 ~]#

[root@maven www]# curl -I 192.168.1.185:10024

HTTP/1.1 200 OK

 技术分享

 

7、项目部署

--简单编码测试,在tomcat项目目录创建下面目录文件

[root@5e1c5f2d9184 webapps]# cat aaa/index.html

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>公司信息</title>

</head>

<body>

<h1>测试</h1>

</body>

 技术分享

Centos7部署Tomcat项目

标签:warning   wan   erp   user   stat   tomcat   png   mnt   send   

原文地址:http://www.cnblogs.com/sunnyyangwang/p/6411525.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!