jdk&tomcat安装
1.上传jdk、tomcat安装包
2.解压两个工具包
#解压tomcat tar -zxvf apache-tomcat-8.5.20.tar.gz #解压jdk tar -zxvf jdk-8u151-linux-x64.tar.gz
3.配置并且测试jdk安装
#配置环境变量
vim /etc/profile#java environment
export JAVA_HOME=/root/soft/jdk1.8.0_151
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH#设置环境变量生效
source /etc/profile
4.启动tomcat
./start.sh
5.防火墙设置
#开放端口
firewall-cmd --zone=public --add-port=8080/tcp --permanent
#跟新防火墙规则
firewall-cmd --reload
#防火墙列表
firewall-cmd --zone=public --list-ports
#防火墙状态
systemctl status firewalld
#启动防火墙
systemctl start firewalld
#关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
MySQL安装
#1.卸载mariadb,否则安装MySql会出现冲突(先查看后删除再查看)
[root@192 ~]# rpm -qa|grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
[root@192 ~]# rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
#3.将MySQL安装包解压到指定目录
tar -xvf mysql-5.7.35-1.el7.x86_64.rpm-bundle.tar
#4.开始安装,-ivh 其中i表示安装,v表示显示安装过程,h表示显示进度
cd mysql-5.7
rpm -ivh mysql-community-common-5.7.35-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.35-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.35-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.35-1.el7.x86_64.rpm
#5.启动MySQL服务
systemctl start mysqld
#6.登录mysql修改密码
[root@192 mysql-5.7]# grep "password" /var/log/mysqld.log
2022-10-12T13:19:16.313408Z 1 [Note] A temporary password is generated for root@localhost: o8N#/CfWD+sh
[root@192 mysql-5.7]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
#设置密码校验策略(0 or LOW),要不密码太LOW不让你过
set global validate_password_policy=0;
#设置密码校验长度,要不密码太短不让你过(多次测试发现密码最小长度为4位)
set global validate_password_length=4;
#更新密码
set password = password("123456");
#数据库没有授权,允许以root身份远程登录mysql
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456';
#输入后使修改生效还需要下面的语句
FLUSH PRIVILEGES;
新建数据库
create database bookshop;
进入到数据库里面
use bookshop;
执行SQL脚本
source /root/soft/book.sql
[root@localhost aa]# cd apache-tomcat-8.5.20/
[root@localhost apache-tomcat-8.5.20]# cd webapps/
[root@localhost webapps]# ls
bs bs.war docs examples host-manager manager ROOT
[root@localhost webapps]# cd bs
[root@localhost bs]# ls
META-INF WEB-INF
[root@localhost bs]# cd WEB-INF/
[root@localhost WEB-INF]# ls
classes lib
[root@localhost WEB-INF]# cd classes/
[root@localhost classes]# ls
application.yml com mapper
[root@localhost classes]# vim application.yml ^C
[root@localhost classes]#[root@localhost classes]# cd /root/aa
[root@localhost aa]# cd apache-tomcat-8.5.20/
[root@localhost apache-tomcat-8.5.20]# cd bin/
[root@localhost bin]# ./shutdown.sh
[root@localhost bin]# ./startup.sh
redis安装
yum install -y gcc
解压redis
tar -zxvf redis-6.2.6.tar.gz
进入解压目录
cd redis-6.2.6
编译
make
进行安装
make install PREFIX=/root/soft/redis
启动
[root@localhost aa]# cd reids
[root@localhost reids]# cd bin
[root@localhost bin]# ./reids-server
[root@localhost bin]# cd ..
[root@localhost reids]# cd /aa
[root@localhost reids]# cd /root/aa
[root@localhost aa]# cd redis-6.2.6/
[root@localhost redis-6.2.6]# mv redis.conf /root/soft/redis/bin
[root@localhost redis-6.2.6]# cd /root/soft/redis/bin
[root@localhost redis-6.2.6]# cd ..
[root@localhost aa]# cd reids
[root@localhost reids]# cd bin
[root@localhost bin]#
修改redis.conf
# bind 127.0.0.1 -::1 75
# protected-mode yes 94
daemonize yes 257
requirepass 123456 901
修改地址
[root@localhost ~]# cd /root/soft/apache-tomcat-8.5.20/
[root@localhost apache-tomcat-8.5.20]# cd webapps/
[root@localhost webapps]# cd bs
[root@localhost bs]# cd WEB-INF/
[root@localhost WEB-INF]# cd classes/
[root@localhost classes]# ls
application.yml com mapper
[root@localhost classes]# vim application.yml
[root@localhost classes]# cd /root/soft/apache-tomcat-8.5.20/
[root@localhost apache-tomcat-8.5.20]# cd bin
[root@localhost bin]# ./shutdown.sh
[root@localhost bin]# ./startup.s
Nginx安装
1) 添加 nginx 官方提供的 yum 源(需要联网且时间较长)
rpm -Uvh http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.14.2-1.el7_4.ngx.x86_64.rpm2) 使用 yum 安装 nginx
yum install nginx注1:yum方式安装nginx,它的安装根目录为/etc/nginx
注2:查看nginx版本
rpm -qa | grep nginx3) 启动及设置开机启动
systemctl start nginx.service
systemctl enable nginx.service
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload配置文件
hosts
[root@localhost bin]# cd /etc/nginx
[root@localhost nginx]# ls
conf.d fastcgi_params koi-utf koi-win mime.types modules nginx.conf scgi_params uwsgi_params win-utf
[root@localhost nginx]#
[root@localhost nginx]# vim nginx.conf
[root@localhost nginx]# cd /usr/local
[root@localhost local]# ls
bin etc games include lib lib64 libexec sbin share src
[root@localhost local]# ls
bin dist etc games include lib lib64 libexec sbin share src
[root@localhost local]# cd dist
[root@localhost dist]# ls
index.html static
[root@localhost dist]# pwd
/usr/local/dist
[root@localhost dist]#检查配置文件是否正常
nginx -t
重启nginx服务
systemctl restart nginxsetenforce 0