tomcat部署安装

Tomcat 运行java程序
LNMP Linux Nginx MySQL PHP 运行PHP程序代码
Nginx静态
Nginx动态 fastcgi_pass ( PHP)
LNMT Linux Nginx MySQL TOMCAT 运行JAVA程序代码
LNMT Linux Nginx MySQL uwsgi 运行Python环境
JVM Java Virtual Machine Java虚拟机
1份代码多个平台使用 代码的可移植性。

Tomcat学习环境搭建:

主机名:
web01 10.0.0.7 172.16.1.7 tomcat大礼包
db01 10.0.0.51 172.16.1.51 安装好mariadb或MySQL

web01

部署JDK Java Development Kit java开发环境

jdk (oracle)
Oracle
微软 GITHUB
OpenJDK

下载jdk

https://www.oracle.com/technetwork/java/javase/downloads/jdk12-downloads-5295953.html

在这里插入图片描述
右击复制下载地址 使用wget 下载

wget https://www.oracle.com/technetwork/java/javase/downloads/jdk12-downloads-5295953.html

[root@web01 tools]# tar xf jdk-8u60-linux-x64.tar.gz 
[root@web01 tools]# mkdir -p /application/
[root@web01 tools]# mv jdk1.8.0_60/  /application/jdk-1.8.0 
[root@web01 tools]# ln -s /application/jdk-1.8.0 /application/jdk
[root@web01 tools]# ll /application/
total 0
lrwxrwxrwx 1 root root  22 Mar 26 16:56 jdk -> /application/jdk-1.8.0
drwxr-xr-x 8   10  143 255 Aug  5  2015 jdk-1.8.0

配置JDK环境变量

[root@web01 tools]# cat >>/etc/profile<<'EOF'
export JAVA_HOME=/application/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
EOF
[root@web01 tools]# . /etc/profile
[root@web01 tools]# java -version 
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
[root@web01 tools]# 

部署Tomcat

[root@web01 tools]# tar xf apache-tomcat-8.0.27.tar.gz 
[root@web01 tools]# ll
total 185912
drwxr-xr-x 9 root root       160 Mar 26 17:07 apache-tomcat-8.0.27
-rw-r--r-- 1 root root   9128610 Oct  5  2015 apache-tomcat-8.0.27.tar.gz
-rw-r--r-- 1 root root 181238643 Oct  5  2015 jdk-8u60-linux-x64.tar.gz
-rw-r--r-- 1 root root       332 Mar 26 16:59 profile.txt
[root@web01 tools]# mv apache-tomcat-8.0.27 /application/tomcat-8.0.27
[root@web01 tools]# ln -s /application/tomcat-8.0.27 /application/tomcat
export TOMCAT_HOME=/application/tomcat

#检测 tomcat jdk环境变量是否ok

[root@web01 tools]# /application/tomcat/bin/version.sh 
Using CATALINA_BASE:   /application/tomcat
Using CATALINA_HOME:   /application/tomcat
Using CATALINA_TMPDIR: /application/tomcat/temp
Using JRE_HOME:        /application/jdk
Using CLASSPATH:       /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar
Server version: Apache Tomcat/8.0.27
Server built:   Sep 28 2015 08:17:25 UTC
Server number:  8.0.27.0
OS Name:        Linux
OS Version:     3.10.0-862.el7.x86_64
Architecture:   amd64
JVM Version:    1.8.0_60-b27
JVM Vendor:     Oracle Corporation

#启动 tomcat

[root@web01 tools]# ls -l /application/tomcat/bin/{startup.,shutdown.,catalina.,version.}*
-rw-r--r-- 1 root root 13825 Sep 28  2015 /application/tomcat/bin/catalina.bat
-rwxr-xr-x 1 root root 21389 Sep 28  2015 /application/tomcat/bin/catalina.sh   #核心
-rw-r--r-- 1 root root  2020 Sep 28  2015 /application/tomcat/bin/shutdown.bat   
-rwxr-xr-x 1 root root  1902 Sep 28  2015 /application/tomcat/bin/shutdown.sh   #关闭
-rw-r--r-- 1 root root  2022 Sep 28  2015 /application/tomcat/bin/startup.bat
-rwxr-xr-x 1 root root  1904 Sep 28  2015 /application/tomcat/bin/startup.sh    #启动
-rw-r--r-- 1 root root  2026 Sep 28  2015 /application/tomcat/bin/version.bat
-rwxr-xr-x 1 root root  1908 Sep 28  2015 /application/tomcat/bin/version.sh
[root@web01 bin]# /application/tomcat/bin/startup.sh 
Using CATALINA_BASE:   /application/tomcat
Using CATALINA_HOME:   /application/tomcat
Using CATALINA_TMPDIR: /application/tomcat/temp
Using JRE_HOME:        /application/jdk
Using CLASSPATH:       /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar
Tomcat started.

#检查进程


[root@web01 bin]# ps -ef |grep java 
root      21656      1 10 17:17 pts/0    00:00:06 
/application/jdk/bin/java 
-Djava.util.logging.config.file=/application/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 
-Djava.endorsed.dirs=/application/tomcat/endorsed 
-classpath /application/tomcat/bin/bootstrap.jar:/application/tomcat/bin/tomcat-juli.jar 
-Dcatalina.base=/application/tomcat 
-Dcatalina.home=/application/tomcat 
-Djava.io.tmpdir=/application/tomcat/temp org.apache.catalina.startup.Bootstrap start
[root@web01 bin]# ss -lntup|grep java 
tcp    LISTEN     0      1      ::ffff:127.0.0.1:8005                 :::*                   users:(("java",pid=21656,fd=76))
tcp    LISTEN     0      100      :::8009                 :::*                   users:(("java",pid=21656,fd=51))
tcp    LISTEN     0      100      :::8080                 :::*                   users:(("java",pid=21656,fd=46))

#tomcat 目录结构说明

[root@web01 tomcat]# ls -l
total 92
drwxr-xr-x 2 root root  4096 Mar 26 17:24 bin   #命令目录 statup.sh  shutdown.sh (检查进程 是否没了)
drwxr-xr-x 3 root root   198 Mar 26 17:17 conf  #server.xml(nginx.conf)  web.xml(用来给tomcat扩展) 
												tomcat-user.xml (tomcat管理用户)
drwxr-xr-x 2 root root  4096 Mar 26 17:07 lib
drwxr-xr-x 2 root root   197 Mar 26 17:17 logs  #tomcat日志 catalina.out  
	[root@web01 tomcat]# ll logs/
	total 24
	-rw-r--r-- 1 root root 6014 Mar 26 17:17 catalina.2019-03-26.log    #catalina.out 的切割日志
	-rw-r--r-- 1 root root 6014 Mar 26 17:17 catalina.out               #默认不会自动清空 
	-rw-r--r-- 1 root root  705 Mar 26 17:21 localhost_access_log.2019-03-26.txt
	
	-rw-r--r-- 1 root root  280 Mar 26 17:17 localhost.2019-03-26.log
	-rw-r--r-- 1 root root    0 Mar 26 17:17 host-manager.2019-03-26.log
	-rw-r--r-- 1 root root    0 Mar 26 17:17 manager.2019-03-26.log
drwxr-xr-x 7 root root    81 Sep 28  2015 webapps   nginx站点目录 root 
drwxr-xr-x 2 root root    30 Mar 26 17:07 temp
drwxr-xr-x 3 root root    22 Mar 26 17:17 work

#tomcat 日志

drwxr-xr-x 2 root root   197 Mar 26 17:17 logs  #tomcat日志 catalina.out  
[root@web01 tomcat]# ll logs/
total 24
-rw-r--r-- 1 root root 6014 Mar 26 17:17 catalina.2019-03-26.log    #catalina.out 的切割日志
-rw-r--r-- 1 root root 6014 Mar 26 17:17 catalina.out               #默认不会自动清空 
-rw-r--r-- 1 root root  705 Mar 26 17:21 localhost_access_log.2019-03-26.txt
db01 
web01 

LNMP 部署wordpress LNMT jpress (java wordpress)

#db01
#查看数据库、表 show
#查看 数据库表格中的某一列(字段 field)的时候
select
#查看
show databases;
show tables from wordpress;
select user,host from mysql.user;
#创建
create database jpress DEFAULT CHARACTER SET utf8;
#添加用户 授予权限
grant all on jpress.* to jpress@‘localhost’ identified by ‘123456’;
grant all on jpress.* to jpress@‘172.16.1.%’ identified by ‘123456’;
所有权限 在 jpress下面所有表 给 jpress用户@只能在本地登录

 #当前在db01 
 mysql -uroot -poldboy123                   #本地登录
 mysql -uroot -poldboy123 -h 数据库ip地址  #远程登录

删除无用的用户

#drop database wordpress;
#drop user ;
MariaDB [wordpress]> drop user ‘’@‘localhost’;
Query OK, 0 rows affected (0.00 sec)
MariaDB [wordpress]> drop user ‘’@‘web01’;
Query OK, 0 rows affected (0.00 sec)
更新权限信息(修改/删除用户的时候)
flush privileges;
#测试jpress是否能用
#scp 172.16.1.51:/usr/bin/mysql /bin/
[root@web01 ~]# mysql -ujpress -p123456 -h 172.16.1.51
[root@web01 tools]# mv jpress-web-newest.war jpress.war
[root@web01 tools]# mv jpress.war /application/tomcat/webapps/
[root@web01 tools]# ls -l /application/tomcat/webapps/
total 20320
drwxr-xr-x 14 root root 4096 Mar 26 17:07 docs
drwxr-xr-x 6 root root 83 Mar 26 17:07 examples
drwxr-xr-x 5 root root 87 Mar 26 17:07 host-manager
drwxr-xr-x 7 root root 102 Mar 26 18:40 jpress
-rw-r–r-- 1 root root 20797013 Mar 3 2017 jpress.war
drwxr-xr-x 5 root root 103 Mar 26 17:07 manager
drwxr-xr-x 3 root root 4096 Mar 26 17:07 ROOT
http://10.0.0.7:8080/jpress/
http://10.0.0.7:8080/jpress/
http://10.0.0.7:8080/jpress/admin
网站所有服务软件的版本
https://blog.oldboyedu.com/java-tomcat/
tomcat剩余
lnmp优化 套路

发布了56 篇原创文章 · 获赞 38 · 访问量 6万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 技术工厂 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览