linux centos7+jsp+tomcat 搭建一个简单得jsp web服务

Centos + Tomcat + JSP

sudo yum install java-1.7.0-openjdk-devel  #安装需要版本得java
yum install tomcat       #安装tomcat
systemctl start tomcat   #启动tomcat服务器
yum install tomcat-webapps 
cd /usr/share/tomcat/webapps #进入tomcat得webapps/ROOT目录:此目录是存放jsp web服务代码得路径
# Delete unnecessary things
mkdir ROOT
cd ROOT
vim webshell.jsp

 任意写一个简单得jsp页面:

<%@ page import="java.io.*"%>
<% Process child = Runtime.getRuntime().exec("cat /etc/hosts");

InputStream in = child.getInputStream();
int c;
while ((c = in.read()) != -1) {
out.print((char)c);
}
%>

通知url直接访问: http://xx.xx.xx.xx:8080/webshell.jsp

ps:

  • tomcat得默认端口是8080
  • jsp root path in wbd Configure page is /usr/share/tomcat/webapps/ROOT

问题解决:

netstat anp | grep 8080 #查看8080端口是那个服务占用

ps -ef | grep tomcat #查看tomcat进程

systemctl start tomcat #启动tomcat服务器
systemctl stop tomcat #停止tomcat服务器
systemctl restart tomcat #重启tomcat服务器

 

posted @ 2024-02-01 11:16  苹果芒  阅读(54)  评论(0编辑  收藏  举报