更新

  1. yum update

安装准备扩展

  1. yum install -y vim wget gcc gcc-c++ libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel epel-release libcurl libcurl-devel libjpeg libjpeg-devel libmcrypt libmcrypt-devel bison bison-devel jemalloc jemalloc-devel zlib-devel mcrypt mhash-devel readline-devel libedit-devel sqlite-devel

安装nginx

  1. [root@localhost ~]# vim /etc/yum.repos.d/nginx.repo
  2. #复制以下内容到nginx.repo
  3. [nginx]
  4. name=nginx repo
  5. baseurl=http://nginx.org/packages/centos/7/$basearch/
  6. gpgcheck=0
  7. enabled=1
  8. [root@localhost ~]# yum -y install nginx
  9. [root@localhost ~]# systemctl start nginx
  10. [root@localhost ~]# systemctl status nginx
  11. [root@localhost ~]# systemctl enable nginx
  12. 关闭防火墙
  13. [root@localhost ~]# systemctl status firewalld
  14. [root@localhost ~]# systemctl stop firewalld

安装MYSQL5.7

  1. //包文件下载到home目录
  2. [root@localhost home]# wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
  3. //使用以下命令安装下载的发布包,用下载包的名称替换特定于平台和版本的包的名称:
  4. [root@localhost home]# rpm -Uvh mysql80-community-release-el7-1.noarch.rpm --force --nodeps
  5. //查询包中所有mysql版本
  6. [root@localhost ~]# yum repolist all | grep mysql
  7. //编辑文件
  8. [root@localhost ~]# vim /etc/yum.repos.d/mysql-community.repo
  9. 修改需要安装的版本
  10. # Enable to use MySQL 5.7
  11. [mysql57-community]
  12. name=MySQL 5.7 Community Server
  13. baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
  14. enabled=1//1为安装
  15. gpgcheck=1
  16. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
  17. [mysql80-community]
  18. name=MySQL 8.0 Community Server
  19. baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
  20. enabled=0//0为不安装
  21. gpgcheck=1
  22. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
  23. //再次查询包中安装的mysql版本是否开启
  24. [root@localhost ~]# yum repolist enabled | grep mysql
  25. //安装mysql
  26. [root@localhost ~]# yum -y install mysql-community-server
  27. //启动mysql
  28. [root@localhost ~]# systemctl start mysqld.service
  29. //设置mysqld服务开机自启动
  30. [root@localhost ~]# systemctl enable mysqld.service
  31. //查询mysql状态
  32. [root@localhost ~]# systemctl status mysqld
  33. //查看mysql安装默认密码
  34. [root@localhost ~]# grep 'temporary password' /var/log/mysqld.log
  35. 2018-10-23T04:01:23.360474Z 1 [Note] A temporary password is generated for root@localhost: e5c8jQ)b3!fX
  36. //修改root密码
  37. ALTER USER 'root'@'localhost' IDENTIFIED BY '2lf2$0fjs23!';
  38. 开启远程连接数据库
  39. mysql> use mysql;
  40. Database changed
  41. mysql> update user set Host = '%' where Host = "localhost" and User = "root";
  42. Query OK, 0 rows affected (0.00 sec)
  43. Rows matched: 0 Changed: 0 Warnings: 0
  44. mysql> flush privileges;
  45. Query OK, 0 rows affected (0.00 sec)

安装php7.1

  1. 安装php源:
  2. rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
  3. rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
  4. 检查源是否安装成功;
  5. yum repolist enabled | grep "webtatic*"
  6. 安装php扩展源:
  7. yum -y install php71w php71w-fpm php71w-mbstring php71w-common php71w-gd php71w-mcrypt php71w-mysql php71w-xml php71w-cli php71w-devel php71w-pecl-memcached php71w-pecl-redis php71w-opcache
  8. 验证php7.1.x和扩展是否安装成功
  9. 验证php是否安装成功
  10. php -v
  11. 验证对应的扩展是否安装成功
  12. php -m
  13. 设置php-fpm并检测php-fpm的运行状态:
  14. 启动php-fpm
  15. systemctl star php-fpm
  16. 检查启动是否成功
  17. systemctl status php-fpm
  18. 设置开机自启动:
  19. systemctl enable php-fpm.service
  20. 检查开机自启动是否设置成功:
  21. systemctl list-dependencies | grep php-fpm
  22. ps -ef | grep php-fpm

分类: Linux

标签: