服务器搭建
阿里云服务器
1.配置阿里云服务器实例入方向的端口:默认的端口+tomcat8080+数据库3306
2.修改服务器实例的登录密码,可以使用Xshell登录服务器
3.登录Xshell,创建jar放置文件夹:uploadFile
4.下载jar到文件夹uploadFile:apache-tomcat-7.0.94.tar.gz/jdk-8u211-linux-x64.tar.gz/mysql80-community-release-el7-2.noarch.rpm
5.进入到uploadFile文件夹下,创建jdk文件夹存放jdk解压文件,解压执行tar -zxvf jdk-8u211-linux-x64.tar.gz -C /usr/local/uploadFile/jdk
6.修改文件,执行命令:vim /etc/profile,在文件下添加信息:
export JAVA_HOME=/usr/local/uploadFile/jdk/jdk1.8.0_211
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
7.执行命令:source /etc/profile加载文件
8.修改后可查看java版本:java -version
9.创建文件夹:mkdir /usr/local/tomcat
10.解压执行tar -zxvf apache-tomcat-7.0.94.tar.gz -C /usr/local/tomcat/
11.进入文件:cd ../tomcat/apache-tomcat-7.0.94/conf/
12.修改文件:vim server.xml
保留:<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
删除下面的连接:<Connector port="80.." />
13.进入tomcat的bin文件夹下
14.配置防火墙,允许端口进入防火墙命令:iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
15.查看防火墙状态:service firewalld status
16.启动/停止tomcat项目:./startup.sh ./shutdown.sh 验证是否启动:ip+端口号或用命令:ps -aux|grep java
17.进入到uploadFile目录下,解压执行:rpm -ivh mysql80-community-release-el7-2.noarch.rpm
18.安装mysql服务:yum install mysql-server
19.执行命令:mysqld --initialize
20.查看mysql的版本:mysqladmin --version
21.修改权限:chown mysql:mysql -R /var/lib/mysql
22.找到mysql配置文件:find / -name my.cnf
修改成:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
character-set-client-handshake=FALSE
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
init_connect='SET NAMES utf8mb4'
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
23.创建mysql文件夹:mkdir -p /var/run/mysqld/
24.修改权限:chown mysql.mysql /var/run/mysqld/
//多余的步骤25
25.配置mysql存储位置:/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
26.启动/停止mysql服务:service mysqld start/sudo systemctl start mysqld.service service mysqld stop
27.mysql服务开机自启:systemctl enable mysqld
28.查看mysql临时密码:grep 'temporary password' /var/log/mysqld.log
29.登录mysql:mysql -uroot -p
30.进入mysql后,允许远程登录mysql配置:
use mysql;
select host,user from user;
update user set host = '%' where user = 'root';
FLUSH PRIVILEGES
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123';
31.把JAVA项目打包放在/usr/local/tomcat/apache-tomcat-7.0.94/webapps下启动tomcat即可