centos7+tomcat7+mysql5.7
创建目录
mkdir /tools
cd /tools
下载apache-tomcat-7.0.92.tar.gz和jdk1.8.0_121
wget http://www.duoduojuan.top/apache-tomcat-7.0.92.tar.gz
wget http://www.duoduojuan.top/jdk-8u121-linux-x64.tar.gz
安装mysql5.7
下载mysql的yum源
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
安装mysql的yum源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
查看安装是否成功
yum repolist enabled | grep "mysql.*-community.*"
可以修改vim /etc/yum.repos.d/mysql-community.repo源,改变默认安装的mysql版本。比如要安装5.6版本,将5.7源的enabled=1改成enabled=0。然后再将5.6源的enabled=0改成enabled=1即可。
安装mysql
yum install mysql-community-server
设置mysql开机启动
systemctl enable mysqld
配置mysql配置文件
mv /etc/my.cnf /etc/my.cnf.bak
vi /etc/my.cnf
###############################################
[client]
default-character-set=utf8 ###设定客户端连接字符集
socket = /mysql/data/mysql.sock
[mysql]
auto-rehash ####自动补全命令
default-character-set=utf8 ####mysql连接字符集
[mysqld]
innodb_buffer_pool_size = 128M
join_buffer_size = 128M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M
#basedir=/usr/share/mysql ###定义MySQL存放位置
datadir=/mysql/data ###设定数据存放位置
socket=/mysql/data/mysql.sock
init_connect='SET collation_connection = utf8_unicode_ci' ###设定服务端字符集
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
symbolic-links=0
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld_safe]
log-error=/mysql/data/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
###############################################
创建mysql数据目录
mkdir -p /mysql/data
chown -R mysql:mysql /mysql/
启动mysql服务
systemctl start mysqld
查看服务是否启动
lsof -i:3306
设置mysql密码
首先停止mysql服务
systemctl stop mysqld
在/etc/my.cnf 中[mysqld]下添加 skip-grant-tables 参数。此参数的作用是登录Mysql 数据库不进行用户密码验证。
####################################
[mysqld]
skip-grant-tables
####################################
保存/etc/my.cnf 后,重新启动mysql
systemctl start mysqld
进入mysql 设置密码(mysql密码规则大小写符号加数字)
mysql -uroot -p
mysql> update mysql.user set authentication_string=password('密码') where user='root';
mysql> flush privileges;
mysql> exit;
去掉/etc/my.cnf 中[mysqld]下 skip-grant-tables 参数,并重启mysql服务
systemctl restart mysqld
进入mysql命令行,修改mysql可以远程访问
mysql>grant all privileges on *.* to 'root'@'%' identified by '密码';
mysql>flush privileges;
mysql -uroot -p
安装jdk
cd /tools
tar -zxf jdk-8u121-linux-x64.tar.gz
mv jdk1.8.0_121/ /usr/local/
chmod +x /usr/local/jdk1.8.0_121
配置java环境变量,在/etc/profile下添加
vi /etc/profile
####################################
JAVA_HOME=/usr/local/jdk1.8.0_121
JAVA_BIN=/usr/local/jdk1.8.0_121/bin
PATH=$PATH:$JAVA_BIN
CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH
############################################
生效环境变量
source /etc/profile
安装tomcat
cd /tools
tar zxf apache-tomcat-7.0.92.tar.gz
mv apache-tomcat-7.0.92 /usr/local/tomcat
修改配置文件
cd /usr/local/tomcat/bin
vim catalina.sh
添加以下内容:
##############################
CATALINA_HOME=/usr/local/tomcat/
##############################
设置可执行权限
cd /usr/local/tomcat/bin
chmod +x *.sh
启动tomcat
/usr/local/tomcat/bin/startup.sh
设置tomcat开机启动
在/usr/local/tomcat/bin/startup.sh开头部分添加java环境变量
################################################
export JAVA_HOME=/usr/local/jdk1.8.0_121
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
export PATH=$PATH:$JAVA_HOME/bin
export CATALINA_HOME=/usr/local/tomcat
################################################
cd /etc/rc.d/
chmod +x rc.local
在/etc/rc.local添加tomcat开机启动
vi rc.local
###########################
/usr/local/tomcat/bin/startup.sh
#############################
tomcat修改端口
vi /usr/local/tomcat/conf/server.xml
############################################
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
###########################################