Linux服务器环境搭建《Redis、Nginx、mysql8安装》

本文详细介绍在Linux环境下安装配置Redis、Nginx及MySQL的过程。包括从下载源码、编译安装到配置服务自动启动的完整步骤,适用于初学者快速上手。

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安装


 
  1. //安装依赖

  2. yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

  3. //进入一个文件夹

  4. cd /usr/local

  5. //创建目录

  6. mkdir nginx

  7. cd nginx

  8. //下载tar包

  9. wget http://nginx.org/download/nginx-1.14.0.tar.gz

  10. tar -xvf nginx-1.14.0.tar.gz

  11. //进入nginx目录

  12. cd /usr/local/nginx

  13. //执行命令

  14. ./configure --with-http_stub_status_module --with-http_ssl_module

  15. //执行make命令

  16. make

  17. //执行make install命令

  18. make install

  19. //编辑nginx.conf

  20. vim /usr/local/nginx/conf/nginx.conf

  21. 在http{}最后面加上

  22. include vhost/*.conf

  23. cd /usr/local/nginx/conf

  24. mkdir vhost

  25. //创建每个域名的配置

  26. vim ***.conf

  27. //进入nginx安装目录

  28. cd /usr/local/nginx/sbin

  29. //启动Nginx

  30. sudo ./nginx

3.mysql8安装


 
  1. cd /usr/local

  2. mkdir mysql

  3. cd mysql

  4. wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm

  5. rpm -ivh mysql80-community-release-el7-1.noarch.rpm

  6. yum install mysql-community-server

  7. //后面需要确认时输入y即可安装成功

  8. service mysqld start

  9. grep "A temporary password" /var/log/mysqld.log

  10. //获取临时密码

  11. mysql -u root -p

  12. //输入上面的临时密码登录

  13. ******

  14. //进入后mysql会提示让你修改临时密码,密码要复杂一点,不然不让通过,要有大小写数字字符

  15. ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '密码';

  16.  
  17. //设置远程连接

  18. use mysql;

  19. update user set host='%' where user='root';

  20. flush privileges;

4.mysql5.7安装

上面安装了mysql8,无奈版本问题还是用5.7吧


 
  1. yum -y install make gcc-c++ cmake bison-devel ncurses-devel libaio libaio-devel

  2. cd /usr/local

  3. mkdir mysql

  4. cd mysql

  5. wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.13-1.el6.x86_64.rpm-bundle.tar

  6. tar xvf mysql-5.7.13-1.el6.x86_64.rpm-bundle.tar

  7. rpm -ivh mysql-community-common-5.7.13-1.el6.x86_64.rpm

  8. rpm -ivh mysql-community-libs-5.7.13-1.el6.x86_64.rpm

  9. rpm -ivh mysql-community-client-5.7.13-1.el6.x86_64.rpm

  10. rpm -ivh mysql-community-server-5.7.13-1.el6.x86_64.rpm

  11. 初始化

  12. mysqld --initialize --user=mysql

  13. 查看初始密码

  14. vim /var/log/mysqld.log

  15. 启动

  16. service mysqld start

  17. 密码在最后一行最后

  18. mysql -u root -p

  19. 输入密码进入后

  20. 修改密码:

  21. alter user 'root'@'localhost' identified by '要修改的密码';

  22. 修改远程连接

  23. use mysql;

  24. update user set user.Host='%' where user.User='root';

  25. flush privileges;

  26. 大功告成

  27. quit

  28. 退出

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值