本文主要是介绍Linux搭建jdk1.8+mysql5.7+nginx1.16.1+redis6.2.5,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
环境搭建(centos 7)
Tip1 设置虚拟机虚拟网络编辑器NAT模式
步骤:1 在虚拟机->编辑->虚拟网络编辑器->Nat模式查看子网IP范围,子网掩码
2 终端->root权限->cd /etc/sysconfig/network-scripts->vim ifcfg-ens33
以下图片参考于网络
3 重启网络配置service network restart->查看IP ifconfig
Tip2 关闭防火墙
查看firewall服务状态:systemctl status firewalld
开启:service firewalld start
重启:service firewalld restart
关闭:service firewalld stop
一劳永逸:systemctl disable firewalld.service
Tip3 安装jdk
1 下载Linux下的jdk-8u371-linux-x64.tar.gz放入/usr/local/tools(tools自己创建)
2 解压tar - zxvf jdk-8u371-linux-x64.tar.gz
3 配置环境变量cd /etc/profile
export JAVA_HOME=/usr/local/tools/jdk1.8_371
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}
Tip4 安装MySQL
1 通过yum安装查看yum源 rpm - qa | grep yum(我的是已存在情况)
2 更新wget yum - y install wget
下载MySQL源 wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
3 安装mysql yum localinstall -y mysql57-community-release-el7-7.noarch.rpm
注意:提示公钥尚未安装 执行rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
4 下一步 yum -y install mysql-community-server
5 查看状态 systemctl status mysqld
6 启动 systemctl start mysqld
7 查看原始密码 grep 'temporary password' /var/log/mysqld.log
8 登录 mysql -uroot -p
9 修改初始密码 alter user 'root'@'localhost' identified by 'fwybh769';
注意:设置简单密码 在Mysql配置文件最后加入:validate_password = off重启后生效
10 配置远程用户登录
.1 指定主机IP grant all privileges on *.* to 'root'@'IP' identified by '密码' with grant option;
.2允许所有 grant all privileges on *.* to 'root'@'%' identified by '密码' with grant option;
11 设置开机自启 systemctl enable mysqld systemctl daemon-reload
12 查看3306端口号 netstat -nltp 连接
Tip5 安装nginx
1 安装依赖包
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
2 下载tar包
wget https://nginx.org/download/nginx-1.16.1.tar.gz
3 解压
tar -xvf nginx-1.16.1.tar.gz
4 安装(在自己的nginx-1.16.1下)
./configure
Make
Make install
5 配置端口号和IP(在系统/usr/local/nginx/conf)
Vim nginx.conf (设置文件大小client_max_body_size 500m;)
6 启动(在/usr/local/nginx/sbin)
./nginx
./nginx -s stop 关闭
./nginx -s reload 重启
7 尝试访问 ip:端口号
8 配置开机自启动
vim /lib/systemd/system/nginx.service
添加:
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx -s reload
ExecStop=/usr/local/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
设置:
systemctl daemon-reload
systemctl enable nginx.service
Tip6 安装redis
1 下载安装包解压
wget http://download.redis.io/releases/redis-6.2.5.tar.gz
tar -zxvf redis-6.2.5.tar.gz
2 切换到redis解压目录下,执行编译
cd redis-6.2.5
make
3 安装并指定安装目录
make install PREFIX=/usr/local/redis
4 复制配置文件
cp /usr/local/redis-6.2.5/redis.conf /usr/local/redis/bin/
5 修改远程连接
Vim redis.conf(bind 0.0.0.0; baemonize yes;requirepass 123456)
6 后台启动(bin/)
./redis-server redis.conf
7 设置开机自启动
vi /etc/systemd/system/redis.service
添加:
[Unit]
Description=redis-server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/bin/redis.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
注意:ExecStart配置成自己的路径
设置:
systemctl daemon-reload
systemctl start redis.service
systemctl enable redis.service
8 创建redis命令软连接
ln -s /usr/local/redis/bin/redis-cli /usr/bin/redis
后续可能继续添加,此环境仅用于个人开发测试
这篇关于Linux搭建jdk1.8+mysql5.7+nginx1.16.1+redis6.2.5的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!