yum在线安装:
查看tomcat相关的安装包:
[root@RHCE ~]# yum list | grep -i tomcat
tomcat.noarch 7.0.76-16.el7_9 @updates
tomcat-el-2.2-api.noarch 7.0.76-16.el7_9 @updates
tomcat-jsp-2.2-api.noarch 7.0.76-16.el7_9 @updates
tomcat-lib.noarch 7.0.76-16.el7_9 @updates
tomcat-servlet-3.0-api.noarch 7.0.76-16.el7_9 @updates
tomcat-webapps.noarch 7.0.76-16.el7_9 @updates
tomcat-admin-webapps.noarch 7.0.76-16.el7_9 updates
tomcat-docs-webapp.noarch 7.0.76-16.el7_9 updates
tomcat-javadoc.noarch 7.0.76-16.el7_9 updates
tomcat-jsvc.noarch 7.0.76-16.el7_9 updates
tomcatjss.noarch 7.2.5-1.el7 base
[root@RHCE ~]#
安装tomcat:
[root@RHCE ~]# yum install tomcat -y
[root@RHCE ~]# yum install tomcat-webapps.noarch -y
启动tomcat:
[root@RHCE ~]# systemctl start tomcat
[root@RHCE ~]# systemctl status tomcat.service
● tomcat.service - Apache Tomcat Web Application Container
Loaded: loaded (/usr/lib/systemd/system/tomcat.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2023-08-05 06:09:35 EDT; 1h 18min ago
Main PID: 2650 (java)
CGroup: /system.slice/tomcat.service
└─2650 /usr/lib/jvm/jre/bin/java -Djavax.sql.DataSource.Factory=org.a...Aug 05 06:09:41 RHCE server[2650]: Aug 05, 2023 6:09:41 AM org.apache.catalina...te
Aug 05 06:09:41 RHCE server[2650]: INFO: At least one JAR was scanned for TLDs...e.
Aug 05 06:09:42 RHCE server[2650]: Aug 05, 2023 6:09:42 AM org.apache.catalina...ry
Aug 05 06:09:42 RHCE server[2650]: INFO: Deployment of web application directo...ms
Aug 05 06:09:42 RHCE server[2650]: Aug 05, 2023 6:09:42 AM org.apache.coyote.A...rt
Aug 05 06:09:42 RHCE server[2650]: INFO: Starting ProtocolHandler ["http-bio-8080"]
Aug 05 06:09:42 RHCE server[2650]: Aug 05, 2023 6:09:42 AM org.apache.coyote.A...rt
Aug 05 06:09:42 RHCE server[2650]: INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Aug 05 06:09:42 RHCE server[2650]: Aug 05, 2023 6:09:42 AM org.apache.catalina...rt
Aug 05 06:09:42 RHCE server[2650]: INFO: Server startup in 3839 ms
Hint: Some lines were ellipsized, use -l to show in full.
检查端口号
[root@RHCE ~]# netstat -lnutp | grep 8080
tcp6 0 0 :::8080 :::* LISTEN 2650/java
使用浏览器测试tomcat是否正常运行,输入主机ip和端口号
RPM包安装:
上传tomcat和jdk包组
安装java的jdk包并检查
[root@localhost ~]# yum localinstall -y jdk-8u261-linux-x64.rpm
[root@localhost ~]# java -version
java version "1.8.0_261"
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)
解压安装tomcat
[root@localhost ~]# tar -xf apache-tomcat-8.5.70.tar.gz -C /usr/local/
[root@localhost ~]# ln -sv /usr/local/apache-tomcat-8.5.70/ /usr/local/tomcat
[root@localhost ~]# tree -d -L 1 /usr/local/tomcat/
/usr/local/tomcat/
├── bin
├── conf
├── lib
├── logs
├── temp
├── webapps
└── work
创建用户tomcat
[root@localhost ~]# groupadd -g 53 tomcat
[root@localhost ~]# useradd -u 53 -g 53 -c "Apache Tomcat" -d /usr/local/tomcat/ -s /sbin/nologin tomcat
[root@localhost ~]# chown -R tomcat.tomcat /usr/local/tomcat/*
编辑tomcat.service文件
[root@localhost ~]# vim /usr/lib/systemd/system/tomcat.service
[Unit]
Description=Apache Tomcat
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
Environment=JAVA_HOME=/usr/java/jdk1.8.0_261-amd64
Environment=CATALINA_HOME=/usr/local/tomcat
ExecStart=/usr/local/tomcat/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExexStop=/bin/kill -s QUIT $MAINPID
User=tomcat
Group=tomcat
FrivateTmp=true
[Install]
WantedBy=multi-user.target
编辑tomcat.conf文件
[root@localhost ~]# vim /usr/local/tomcat/conf/tomcat.conf
TOMCAT_CFG_LOADED="1"
TOMCATS_BASE="/usr/local/tomcat/"
# Where your java installation lives
JAVA_HOME="/usr/java/jdk1.8.0_261-amd64/jre/"
# Where your tomcat installation lives
CATALINA_HOME="/usr/local/tomcat"
# System-wide tmp
CATALINA_TMPDIR="/usr/local/tomcat/temp"
# Set default javax.sql.DataSource factory to apache commons one. See rhbz#1629162
JAVA_OPTS="-Djavax.sql.DataSource.Factory=org.apache.commons.dbcp.BasicDataSourceFactory"
# Run tomcat under the Java Security Manager
SECURITY_MANAGER="false"
启动tomcat 并设置开机启动
[root@localhost ~]# systemctl enable --now tomcat
Created symlink from /etc/systemd/system/multi-user.target.wants/tomcat.service to /usr/lib/systemd/system/tomcat.service.
[root@localhost ~]# systemctl status tomcat
● tomcat.service - Apache Tomcat
Loaded: loaded (/usr/lib/systemd/system/tomcat.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2023-08-02 19:06:12 CST; 5s ago
Process: 3421 ExecStart=/usr/local/tomcat/bin/startup.sh (code=exited, status=0/SUCCESS)
Main PID: 3428 (java)
CGroup: /system.slice/tomcat.service
└─3428 /usr/java/jdk1.8.0_261-amd64/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logg...
Aug 02 19:06:12 localhost.localdomain systemd[1]: Starting Apache Tomcat...
Aug 02 19:06:12 localhost.localdomain systemd[1]: Started Apache Tomcat.
[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.16.131 netmask 255.255.255.0 broadcast 192.168.16.255
inet6 fe80::7b78:36ce:2fc3:c570 prefixlen 64 scopeid 0x20<link>
inet6 fe80::921e:3b9f:4a3c:f930 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:67:ed:f2 txqueuelen 1000 (Ethernet)
RX packets 105049 bytes 144206992 (137.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 10163 bytes 1114107 (1.0 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
通过浏览器测试受否能够打开
部署jpress
查看是否有足够的熵来产生随机数
[root@RHCE ~]# cat /proc/sys/kernel/random/entropy_avail
436
不够则安装rngd解决
[root@localhost ~]# yum install -y rng-tools
[root@localhost ~]# systemctl enable --now rngd
Tomcat Web管理功能(注意:需设置可访问管理主机的IP地址,确保安全)
配置tomcat-users.xml文件(注意:在<tomcat-users>和</tomcat-usesr>之间添加)
[root@localhost ~]# vim /usr/local/tomcat/conf/tomcat-users.xml
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="manager-gui"/>
<role rolename="manager-jmx"/>
<role rolename="manager-script"/>
<role rolename="manager-status"/>
<user username="tomcat" password="tomcat" roles="admin-gui,admin-script,manager-gui,manager-jmx,manager-script,manager-status"/>
允许方式Manager App,更改allow="可访问管理Tomcat的主机地址"
[root@localhost ~]# vim /usr/local/tomcat/webapps/manager/META-INF/context.xml
<Context antiResourceLocking="false" privileged="true" >
<CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
sameSiteCookies="strict" />
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="192.168.100.146" />
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>
允许访问HOST Manager
[root@localhost ~]# vim /usr/local/tomcat/webapps/host-manager/META-INF/context.xml
<Context antiResourceLocking="false" privileged="true" >
<CookieProcessor className="org.apache.tomcat.util.http.Rfc6265CookieProcessor"
sameSiteCookies="strict" />
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="192.168.100.146" />
<Manager sessionAttributeValueClassNameFilter="java\.lang\.(?:Boolean|Integer|Long|Number|String)|org\.apache\.catalina\.filters\.CsrfPreventionFilter\$LruCache(?:\$1)?|java\.util\.(?:Linked)?HashMap"/>
</Context>
重启tomcat 浏览器访问访问
输入用户名和密码后出现如下界面
静态网页和动态网页的区别
1. 静态网页:
- 静态网页是由服务器上存储的预先创建好的HTML、CSS和JavaScript等静态文件组成的。
- 当用户请求访问静态网页时,服务器直接将保存在硬盘上的静态网页文件发送给用户的浏览器,并由浏览器解析和呈现网页内容。
- 静态网页内容在每次访问时都是相同的,不会根据用户或其他条件的变化而改变。
- 通常用于展示不需要频繁更新内容的网页,如公司介绍、产品展示等。
2. 动态网页:
- 动态网页的内容是根据用户请求或其他条件在服务器端动态生成的。
- 当用户请求访问动态网页时,服务器通过服务器端脚本处理用户请求,并从数据库中获取数据、进行计算等操作后,生成一个HTML网页文件,并将其发送给用户的浏览器进行解析和呈现。
- 动态网页的内容可以根据用户的特定需求、登录状态、交互操作或其他条件的变化而改变。
- 通常用于需要与用户交互、提供实时更新内容的网页,如社交媒体、电子商务网站等。
web1.0和2.0的区别
1.Web1.0是被动的信息消费模式,只允许用户在网站上接受信息,不能进行交互和参与;而Web2.0则是一种更加交互式的网络环境,用户可以像参与社交网络那样自由地发布、共享信息,并通过评论、点赞等方式与其他用户互动。
2.内容形式:Web1.0主要是静态页面,内容主要以文字、图片、声音和视频资料为主;而Web2.0则更注重多媒体交互效果,包括在线直播、社交分享、流畅的动画效果等。
3.技术手段:Web1.0采用的是前端开发技术如HTML、CSS和JavaScript,后端则主要是静态网页服务器(如Apache);而Web2.0则采用了更多的技术手段如AJAX、HTML5、WEB API等,能够更好地支持多媒体展示、即时通信、云计算等功能。
4.数据处理:Web1.0主要强调数据的呈现,网页信息的发布、分类、搜索等都是围绕着展示信息本身进行设计的;而Web2.0则更关注数据的处理和分析,用户行为数据、动态社交关系等成为业务中重要的一环。