Linux服务器环境搭建《Redis、Nginx、mysql8安装》
1.Redis安装
直接操作:
cd /
cd /usr/local
mkdir redis
cd redis
wget http://download.redis.io/releases/redis-4.0.10.tar.gz 下载
tar xzf redis-4.0.10.tar.gz 解压
cd redis-4.0.10
make
cd src
make install
到此redis已经安装完毕
配置:
上面步骤都执行完毕后就需要配置redis了,配置其自动启动:
$ cd /usr/local/redis/redis-4.0.10
$ cd utils
$ cp redis_init_script /etc/init.d/redis
$ cd ..
$ mkdir /etc/redis
$ cp redis.conf /etc/redis/6379.conf
$ vim /etc/redis/6379.conf
将daemonize no修改为daemonize yes
$ vim /etc/init.d/redis 这一步不需要
$ chkconfig redis on
$ service redis start 启动redis服务
$ service redis stop 关闭redis服务
2.Nginx安装
-
//安装依赖
-
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
-
//进入一个文件夹
-
cd /usr/local
-
//创建目录
-
mkdir nginx
-
cd nginx
-
//下载tar包
-
wget http://nginx.org/download/nginx-1.14.0.tar.gz
-
tar -xvf nginx-1.14.0.tar.gz
-
//进入nginx目录
-
cd /usr/local/nginx
-
//执行命令
-
./configure --with-http_stub_status_module --with-http_ssl_module
-
//执行make命令
-
make
-
//执行make install命令
-
make install
-
//编辑nginx.conf
-
vim /usr/local/nginx/conf/nginx.conf
-
在http{}最后面加上
-
include vhost/*.conf
-
cd /usr/local/nginx/conf
-
mkdir vhost
-
//创建每个域名的配置
-
vim ***.conf
-
//进入nginx安装目录
-
cd /usr/local/nginx/sbin
-
//启动Nginx
-
sudo ./nginx
3.mysql8安装
-
cd /usr/local
-
mkdir mysql
-
cd mysql
-
wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm
-
rpm -ivh mysql80-community-release-el7-1.noarch.rpm
-
yum install mysql-community-server
-
//后面需要确认时输入y即可安装成功
-
service mysqld start
-
grep "A temporary password" /var/log/mysqld.log
-
//获取临时密码
-
mysql -u root -p
-
//输入上面的临时密码登录
-
******
-
//进入后mysql会提示让你修改临时密码,密码要复杂一点,不然不让通过,要有大小写数字字符
-
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '密码';
-
//设置远程连接
-
use mysql;
-
update user set host='%' where user='root';
-
flush privileges;
4.mysql5.7安装
上面安装了mysql8,无奈版本问题还是用5.7吧
-
yum -y install make gcc-c++ cmake bison-devel ncurses-devel libaio libaio-devel
-
cd /usr/local
-
mkdir mysql
-
cd mysql
-
wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.13-1.el6.x86_64.rpm-bundle.tar
-
tar xvf mysql-5.7.13-1.el6.x86_64.rpm-bundle.tar
-
rpm -ivh mysql-community-common-5.7.13-1.el6.x86_64.rpm
-
rpm -ivh mysql-community-libs-5.7.13-1.el6.x86_64.rpm
-
rpm -ivh mysql-community-client-5.7.13-1.el6.x86_64.rpm
-
rpm -ivh mysql-community-server-5.7.13-1.el6.x86_64.rpm
-
初始化
-
mysqld --initialize --user=mysql
-
查看初始密码
-
vim /var/log/mysqld.log
-
启动
-
service mysqld start
-
密码在最后一行最后
-
mysql -u root -p
-
输入密码进入后
-
修改密码:
-
alter user 'root'@'localhost' identified by '要修改的密码';
-
修改远程连接
-
use mysql;
-
update user set user.Host='%' where user.User='root';
-
flush privileges;
-
大功告成
-
quit
-
退出