目录
一、yum安装
二、通用二进制安装
1、创建组和用户(参考yum安装)
2、解压并创建软连接
3、设置所属组和所属用户
4、编写服务脚本
5、启动tomcat
#如果tomcat启动慢可以查看随机数
6、配置tomcat-users.xml
7、配置两个位置的context.xml
三、部署
1、memtest
2、zrlog
3、jpress
安装epel
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
安装tomcat系列包
yum install tomcat.noarch tomcat-admin-webapps.noarch tomcat-webapps.noarch
启动tomcat
systemctl start tomcat
检查端口是否启动
[root@host2 ~]# netstat -lnupt | grep 8080
tcp6 0 0 :::8080 :::* LISTEN 14820/java
关掉防火墙设置selinux
vim /etc/sysconfig/selinux
此时在网页上可以通过ip加端口形式访问
注意:tomcat和jdk版本要相适应
往linux系统中上传jdk的rpm包
安装jdk
yum install jdk-8u261-linux-x64.rpm -y
根据需求官网下载tomcat的二进制压缩包
wget -c https://archive.apache.org/dist/tomcat/tomcat-8/v8.0.36/bin/apache-tomcat-8.0.36.tar.gz
[root@host1 ~]# ll
total 132580
-rw-------. 1 root root 1450 Dec 13 12:24 anaconda-ks.cfg
-rw-r--r--. 1 root root 7192576 Jun 9 21:27 apache-tomcat-8.0.36.tar.gz
-rw-r--r--. 1 root root 127431820 Jan 3 16:34 jdk-8u261-linux-x64.rpm
groupadd -r -g 53 tomcat
useradd tomcat -r -g 53 -u 53 -c "Apache Tomcat" -s /sbin/nologin -d /usr/local/tomcat
tar xf apache-tomcat-8.0.36.tar.gz -C /usr/local/
ln -sv /usr/local/apache-tomcat-8.0.36/ /usr/local/tomcat
chown -R tomcat:tomcat /usr/local/tomcat/*
[root@host1 ~]# ll /usr/local/tomcat/
total 92
drwxr-xr-x. 2 tomcat tomcat 4096 Jun 9 21:53 bin
drwxr-xr-x. 3 tomcat tomcat 198 Jun 9 22:17 conf
drwxr-xr-x. 2 tomcat tomcat 4096 Jun 9 21:53 lib
-rw-r--r--. 1 tomcat tomcat 57011 Jun 9 2016 LICENSE
drwxr-xr-x. 2 tomcat tomcat 197 Jun 9 22:17 logs
-rw-r--r--. 1 tomcat tomcat 1444 Jun 9 2016 NOTICE
-rw-r--r--. 1 tomcat tomcat 6739 Jun 9 2016 RELEASE-NOTES
-rw-r--r--. 1 tomcat tomcat 16195 Jun 9 2016 RUNNING.txt
drwxr-xr-x. 2 tomcat tomcat 30 Jun 9 21:53 temp
drwxr-xr-x. 7 tomcat tomcat 81 Jun 9 2016 webapps
drwxr-xr-x. 3 tomcat tomcat 22 Jun 9 22:17 work
vim /usr/lib/systemd/system/tomcat.service
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.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/catalina.sh start
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
User=tomcat
Group=tomcat
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl start tomcat.service
[root@host1 ~]# cat /proc/sys/kernel/random/entropy_avail
1896
增大方法
yum install rng-tools -y
systemctl enable rngd
[root@host1 ~]# vim /usr/local/tomcat/conf/tomcat-users.xml
vim /usr/local/tomcat/webapps/host-manager/META-INF/context.xml
vim /usr/local/tomcat/webapps/host-manager/META-INF/context.xml
接下来网页访问ip和端口,红色框这里可以访问、登录
上传包网页访问即可
安装数据库并开启
yum install mariadb-server
systemctl start mariadb
创建数据库并授权用户
MariaDB [(none)]> create database zrlog default character set utf8;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on zrlog.* to zrlog@'localhost' identified by '123456';
Query OK, 0 rows affected (0.01 sec)
创建数据库并授权用户
MariaDB [(none)]> create database jpress default character set utf8;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on jpress.* to jpress@'localhost' identified by '123456';Query OK, 0 rows affected (0.00 sec)