一、linux下安装java、tomcat
- centos上传jdk、tomcat安装包
使用winscp将下载好的jdk包(jdk-8u201-linux-x64.tar.gz)、tomcat包(apache-tomcat-9.0.14.tar.gz)上传到centos目录 /software 下面 - 解压缩安装包
[root@localhost software]# tar -zxvf jdk-8u201-linux-x64.tar.gz
[root@localhost software]# ls
apache-tomcat-9.0.14.tar.gz jdk1.8.0_201 jdk-8u201-linux-x64.tar.gz - 修改/etc/profile文件
在这个文件的最末尾加上
export JAVA_HOME=/software/jdk1.8.0_201
export PATH=$JAVA_HOME/bin:$PATH - 使这个/etc/profile文件生效
[root@localhost software]# source /etc/profile
- 测试jdk环境
[root@localhost ~]# pwd
/root
[root@localhost ~]# java -version
java version “1.8.0_201”
Java™ SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot™ 64-Bit Server VM (build 25.201-b09, mixed mode) - 关闭防火墙(必须关闭防火墙,否则tomcat无法通过其他机器访问)
[root@localhost logs]# systemctl stop firewalld.service
另:启动防火墙
[root@localhost apache-tomcat-9.0.14]# systemctl start firewalld.service
解释:防火墙会每次随着系统启动,要禁用防火墙的开机自动启动
[root@localhost bin]# systemctl disable firewalld.service
开启防火前自动启动
[root@localhost bin]# systemctl enable firewalld.service
- 解压缩tomcat包
[root@localhost software]# tar -zxvf apache-tomcat-9.0.14.tar.gz
[root@localhost software]# ls apache-tomcat-9.0.14
bin conf lib logs README.md RUNNING.txt webapps
BUILDING.txt CONTRIBUTING.md LICENSE NOTICE RELEASE-NOTES temp work - 启动tomcat
[root@localhost bin]# ./startup.sh
Using CATALINA_BASE: /software/apache-tomcat-9.0.14
Using CATALINA_HOME: /software/apache-tomcat-9.0.14
Using CATALINA_TMPDIR: /software/apache-tomcat-9.0.14/temp
Using JRE_HOME: /software/jdk1.8.0_201
Using CLASSPATH: /software/apache-tomcat-9.0.14/bin/bootstrap.jar:/software/apache-tomcat-9.0.14/bin/tomcat-juli.jar
Tomcat started.
9.浏览器访问,可以看到效果
http://192.168.114.134:8080/ - 查看tomcat运行的进程
[root@localhost bin]# ps aux |grep tomcat
root 16243 2.3 6.9 2996844 129000 pts/0 Sl 16:37 0:03 /software/jdk1.8.0_201/bin/java -Djava.util.logging.config.file=/software/apache-tomcat-9.0.14/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /software/apache-tomcat-9.0.14/bin/bootstrap.jar:/software/apache-tomcat-9.0.14/bin/tomcat-juli.jar -Dcatalina.base=/software/apache-tomcat-9.0.14 -Dcatalina.home=/software/apache-tomcat-9.0.14 -Djava.io.tmpdir=/software/apache-tomcat-9.0.14/temp org.apache.catalina.startup.Bootstrap start
root 16398 0.0 0.0 112708 976 pts/0 S+ 16:39 0:00 grep --color=auto tomcat - 查看tomcat启动的日志
[root@localhost bin]# cat ../logs/catalina.out
…
19-Jan-2019 16:37:20.953 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [“http-nio-7080”]
19-Jan-2019 16:37:20.963 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [“ajp-nio-7009”]
19-Jan-2019 16:37:20.969 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [498] milliseconds
二、tail和head命令
-
显示一个文件的开始几行
[root@localhost ~]# cat demo.txt
1
2
3
4
5
6
7
8
9
10
11
12
[root@localhost ~]# head -n 10 demo.txt |tail -n 3
8
9
10 -
显示一个文件的结尾几行
[root@localhost ~]# cat demo.txt
1
2
3
4
5
6
7
8
9
10
11
12
[root@localhost ~]# tail -n 3 demo.txt
10
11
12 -
实时监控一个文件的末尾
[root@localhost ~]# tail -f demo.txt
6
7
8
9
10
11
12 -
显示一个文件的第8到第10行
[root@localhost ~]# head -10 demo.txt | tail -n 3
8
9
10