参考资料:

https://www.cnblogs.com/sxdcgaq8080/p/7492426.html

https://blog.csdn.net/ds986619036/article/details/80885917

https://blog.csdn.net/ds986619036/article/details/80885917

https://blog.csdn.net/Rain_xiaolong/article/details/80569972

腾讯云服务器配置环境前请先设置安全组

jdk安装

1.先检查原服务器上是否已经安装了java jdk,如果已安装可以先卸载

2.下载jdk:jdk-8u212-linux-x64.tar.gz

3.将jdk复制到/usr/local/src/下(可以使用xftp传输)

4.解压:先定位到当前目录

执行解压命令:tar  -zxvf  jdk-8u212-linux-x64.tar.gz

5.配置环境变量

5.1执行:vim /etc/profile   打开文件

5.2移动光标到末尾

5.3在末尾追加:

#java environment
export JAVA_HOME=/usr/local/src/jdk1.8.0_212
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin

执行:esc

执行::wq!

5.4刷新配置文件,验证JDK是否配置成功:

先定为到 /etc目录,然后执行

source /etc/profile

java -version

tomcat安装

1.下载:https://tomcat.apache.org/download-90.cgi

2.将jtomcat复制到/usr/local/src/下(可以使用xftp传输)

3.解压:tar -axvf   apache-tomcat-9.0.29.tar.gz

4.配置环境变量

vim /etc/profile

做如下配置:

刷新配置:

5.修改端口及域名指向

将/usr/local/src/apache-tomcat-9.0.29/conf下的server.xml下载到自己电脑上

端口号修改为80

    <Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

绑定网站

 <Host name="java.xxx.com"  appBase="webapps"
unpackWARs="true" autoDeploy="true"> <!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
--> <!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t &quot;%r&quot; %s %b" /> <Context path="/" docBase="web_ssm.war" debug="0" previledge="true" reloadable="true"/> </Host>

如需要绑定多个域名,可以增加多个Host节点

********如上配置运行网站时报错如下:************************

Tomcat Manager App--403 Access Denied You are not authorized to view this page

解决方案是:

修改webapps/manager/META-INF//META-INF/context.xml

将value标签注释掉

 **************再次运行网站报错如下:*******************

404 Not found

The page you tried to access (/manager/index) does not exist.

The Manager application has been re-structured for Tomcat 7 onwards and some of URLs have changed. All URLs used to access the Manager application should now start with one of the following options:

  • /manager/html for the HTML GUI
  • /manager/text for the text interface
  • /manager/jmxproxy for the JMX proxy
  • /manager/status for the status pages

Note that the URL for the text interface has changed from "/manager" to "/manager/text".

You probably need to adjust the URL you are using to access the Manager application. However, there is always a chance you have found a bug in the Manager application. If you are sure you have found a bug, and that the bug has not already been reported, please report it to the Apache Tomcat team.

URL 不能以/manager开头,将所有以/manager开头的url改掉就解决了

6.把war包放到tomcat安装目录下的webapps目录

7.开启80端口

sudo firewall-cmd --zone=public --add-port=/tcp --permanent 

7.1重启防火墙

sudo systemctl restart firewalld.service

8.启动和关闭tomcat

启动:/usr/local/src/apache-tomcat-9.0.29/bin/startup.sh
关闭:/usr/local/src/apache-tomcat-9.0.29/bin/shutdown.sh

9.设置开机自动启动

9.1在目录/usr/local/src/apache-tomcat-9.0.29/bin创建setenv.sh文件

#catalina.sh在执行的时候会调用同级路径下的setenv.sh来设置额外的环境变量

文件内容:

export CATALINA_HOME=/usr/local/src/apache-tomcat-9.0.
export CATALINA_BASE=/usr/local/src/apache-tomcat-9.0.
#设置Tomcat的PID文件
CATALINA_PID="$CATALINA_BASE/tomcat.pid"
#添加JVM选项
JAVA_OPTS="-server -XX:PermSize=256M -XX:MaxPermSize=1024m -Xms512M -Xmx1024M -XX:MaxNewSize=256m"

9.2编写tomcat.service文件,在/usr/lib/systemd/system路径下添加tomcat.service文件,内容如下:

[Unit]
Description=Tomcat9.0.29
After=syslog.target network.target remote-fs.target nss-lookup.target [Service]
Type=forking PIDFile=/usr/local/src/apache-tomcat-9.0./tomcat.pid
ExecStart=/usr/local/src/apache-tomcat-9.0./bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true [Install]
WantedBy=multi-user.target

9.3设置开机启动tomcat.service

systemctl enable tomcat.service

9.4启动tomcat

systemctl start tomcat.service

**********报错如下:***************************************************

Job for tomcat.service failed because the control process exited with error code. See "systemctl status tomcat.service" and "journalctl -xe" for details.

执行:systemctl status tomcat.servic  查看详细报错详细如下:

● tomcat.service - Tomcat9.0.29
Loaded: loaded (/usr/lib/systemd/system/tomcat.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2019-12-05 17:43:06 CST; 21s ago
Process: 6097 ExecStart=/usr/local/src/apache-tomcat-9.0.29/bin/startup.sh (code=exited, status=1/FAILURE)

Dec 05 17:43:06 VM_0_2_centos systemd[1]: Starting Tomcat9.0.29...
Dec 05 17:43:06 VM_0_2_centos startup.sh[6097]: Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
Dec 05 17:43:06 VM_0_2_centos startup.sh[6097]: At least one of these environment variable is needed to run this program
Dec 05 17:43:06 VM_0_2_centos systemd[1]: tomcat.service: control process exited, code=exited status=1
Dec 05 17:43:06 VM_0_2_centos systemd[1]: Failed to start Tomcat9.0.29.
Dec 05 17:43:06 VM_0_2_centos systemd[1]: Unit tomcat.service entered failed state.
Dec 05 17:43:06 VM_0_2_centos systemd[1]: tomcat.service failed.

 解决错误:

修改/usr/local/src/apache-tomcat-9.0.29/bin下的catalina.sh 文件,在文件顶部加入如下代码:

export JAVA_HOME=/usr/local/src/jdk1..0_212
export JRE_HOME=/usr/local/src/jdk1..0_212/jre

重新启动tomcat:systemctl start tomcat.service

重新查看tomcat服务状态:systemctl status tomcat

9.5.常用命令

开机启动
systemctl enable tomcat.service
移除开机启动
systemctl disable tomcat.service
开机禁止启动
systemctl disable tomcat.service
启动tomcat
systemctl start tomcat.service
关闭tomcat
systemctl stop tomcat.service
重启
systemctl restart tomcat.service

mysql安装

1.下载安装包

wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm

下载到/usr/local/src目录下面

2.安装mysql源

3.检查mysql源是否安装成功

yum repolist enabled | grep "mysql.*-community.*"

4.安装MySQL服务端

yum install mysql-community-server

5.启动MySQL服务

等同于命令:systemctl start mysqld
service mysqld start

重启命令是:service mysqld restart

6.检查mysql 的运行状态

service mysqld status

7.修改root本地登录密码

7.1查看初始密码

grep 'temporary password' /var/log/mysqld.log

7.2用初始密码登录

mysql -uroot -p

7.3修改初始密码

set password for 'root'@'localhost'=password('密码');

注意:mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误

8.授权其他机器登陆

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Root@123456' WITH GRANT OPTION;

FLUSH  PRIVILEGES;

9.退出mysql

10.防火墙开启3306端口

10.1执行:sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent

********报错如下:防火墙未开启*******

10.2开启防火墙

通过systemctl status firewalld查看firewalld状态,发现当前是dead状态,即防火墙未开启。

通过systemctl start firewalld开启防火墙,没有任何提示即开启成功。

再次通过systemctl status firewalld查看firewalld状态,显示running即已开启了。

如果要关闭防火墙设置,可能通过systemctl stop firewalld这条指令来关闭该功能。

10.3防火墙开启3306端口

sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent

10.4重启防火墙

sudo systemctl restart firewalld.service

10.5查看所有开启的端口命令:firewall-cmd --list-ports

11.测试连接:

12.设置mysql开机启动

systemctl enable mysqld
systemctl daemon-reload

13.mysql命令

停止
service mysqld stop
开启
service mysqld start
重启
service mysqld restart

14.mysql部署到服务器时经常报错如下:

### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 141,839,270 milliseconds ago. The last packet sent successfully to the server was 141,839,271 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
### The error may exist in file [/usr/local/src/apache-tomcat-9.0.29/webapps/ROOT/WEB-INF/classes/com/eggtwo/euq/entity/MemberMapper.xml]
### The error may involve com.eggtwo.euq.dao.MemberMapper.selectByLoginName-Inline
### The error occurred while setting parameters
### SQL: select id, loginName, saltKey, loginPassword, relName, email, phone, admin, deleted, createdTime from mms_member where loginName = ?
### Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 141,839,270 milliseconds ago. The last packet sent successfully to the server was 141,839,271 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
; SQL []; The last packet successfully received from the server was 141,839,270 milliseconds ago. The last packet sent successfully to the server was 141,839,271 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 141,839,270 milliseconds ago. The last packet sent successfully to the server was 141,839,271 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.

解决方案如下:

参考:https://blog.csdn.net/qiushisoftware/article/details/77718634

https://developer.aliyun.com/ask/78524?spm=a2c6h.13159736

https://msd.misuland.com/pd/3255818066314920538

第一步:查找my.cnf文件,查找的结果是在/etc目录下

修改my.cnf文件:

修改MySQL的参数,wait_timeout最大为31536000即1年,在my.cnf中加入:

wait_timeout=
interactive_timeout=

重启mysql服务

service mysqld restart

centos7.5安装java JDK、tomcat、mysql的更多相关文章

  1. Linux安装java jdk、mysql、tomcat

    安装javajdk 1.8 检查是否安装 rpm -qa | grep jdk rpm方式安装 下载java1.8 jdk http://download.oracle.com/otn-pub/jav ...

  2. ubuntu安装配置jdk tomcat mysql ...

    安装之前大家一定要检查好各个版本问题 以免造成不兼容. (一)下载所需安装包: jdk-7u76-linux-x64.tar.gz apache-tomcat-7.0.63.tar.gz MySQL- ...

  3. Ubuntu下安装配置JDK,Tomcat,MySql

    jdk安装配置 下载jdk-6u45-linux-x64.bin 切换到root用户su root 切换目录,新建文件夹,复制文件cd /usr      mkdir javacd javacp 路径 ...

  4. Linux安装部署jdk+tomcat+mysql

    Linux安装部署测试环境 1. JDK安装下载 安装 yum search jdk 找到合适的jdk版本,以下图中的版本为例 yum install java-1.8.0-openjdk.x86_6 ...

  5. Linux安装Jdk Tomcat MySQL

    Jdk安装 Tomcat安装 Mysql安装 Jdk安装 官网下载 http://www.oracle.com/technetwork/java/javase/downloads/index.html ...

  6. ubuntu下安装jdk,tomcat,mysql,ftp,telnet,svn

    需求分析:自己弄了个小网站,想放到云服务器上,同时把自己积累的代码也放上去,服务器上的文件可以简单的在windows上查看,也可以方便的通过windows连接linux服务器. 解决:运行网站要用到j ...

  7. mac在 aliyun linux ecs实例上安装 jdk tomcat mysql

    用了一个ftp 工具 把 gz rpm 等 传递到ecs 上 -- 用这个Transmit 用ssh远程登录,然后依次安装 jdk tomcat  mysql 到 /usr/local/... 设置环 ...

  8. win10下安装java jdk,tomcat

    1.安装java jdk 去官网下载java jdk(http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-21 ...

  9. linux 下 jdk+tomcat+mysql 的 jsp 环境搭建

    JDK 在 linux 下安装 1.          把安装文件放在 /opt 下,并执行 [root@localhost opt]# ./jdk-1_5_0_06-linux-i586.bin 并 ...

随机推荐

  1. 压缩20M文件从30秒到1秒的优化过程

    文章来源公众号:IT牧场 有一个需求需要将前端传过来的10张照片,然后后端进行处理以后压缩成一个压缩包通过网络流传输出去.之前没有接触过用Java压缩文件的,所以就直接上网找了一个例子改了一下用了,改 ...

  2. win10 net framework 3.5提示错误代码0x800f081f

    重装了win10系统,碰到以下几个问题 1.安装本地iis -启动或关闭windonws功能- 安装net framework 3.5的时候 提示错误代码0x800f081f 2.安装SqlServe ...

  3. python常用库简单使用( PyPDF2 )

    PyPDF2学习 1  这个模块的名字对大小写是敏感的,所以,确保y是小写的,其他字母都是大写的

  4. Java面向对象——相关基本定义

    Java面向对象——相关基本定义 摘要:本文简单介绍了面向对象的编程方式,以及与之有关的一些基本定义. 面向对象 什么是面向对象 面向对象编程是一种对现实世界建立计算机模型的一种编程方法.简称OOP( ...

  5. npm和cnpm命令后无响应

    问题: 1.把前端环境配制完毕之后,打开项目,输入cnpm install之后,光标一直在另起一行的位置闪,但是丝毫没有在安装的迹象. 2.打开cmd,在窗体中输入node -v 可以显示版本,但是输 ...

  6. gsoap工具生成wsdl接口 注意事项

    wsdl是通过wsdl文件作为不同应用的通信接口,所以如何生成wsdl语言很重要,但是很多时候我们发现自己编写的头文件通过gsoap工具soapcpp2.exe从头文件中无法正常生成对应的wsdl语言 ...

  7. Windows中将nginx添加到服务(转)

    下载安装nginx http://nginx.org/en/download.html 下载后解压到C盘 C:\nginx-1.14.0 添加服务 需要借助"Windows Service ...

  8. i春秋暑期训练营丨渗透测试工程师开课啦

    每个人的夏天 都有专属的解锁方式 或来一次难忘的旅行 或躺在家里吹着空调吃西瓜 又或者是和小伙伴参加暑期训练营 i春秋暑期渗透测试工程师 报名通道已全部开启 为了保证课程质量,采取小班教学,每班仅限3 ...

  9. java并发查询数据

    并发服务 package com.springboot_android.thread; import com.project_entity.bean.DeviceRecrodBean; import ...

  10. SqlServer数据库优化之添加主键和自增长

    今天需要给有500万条数据的表添加主键和自增长列,其中最大的难度在于如何UPDATE这500万多条数据,开始吧! 1.先给表添加一个字段叫ID,并允许空 2.查询表,我想到了使用其中的时间列排序来创建 ...