yum 快速搭建 lnmp 开发环境

  • linux是使用的云主机 我选择的是centos7.4
  • PHP 7.2.4 下载

    • yum -y remove php* 先卸载之前安装的
    • 更改yum源 ,支持 php7.x
    rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm   
    rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 
    • yum 安装php72w和各种拓展
    yum -y install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml
  • Nginx 最新 stable vrsion 下载
  • mysql 5.7

    • 下载mysql源安装包
    wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
    • 安装mysql源
    yum localinstall mysql57-community-release-el7-8.noarch.rpm
    • 检查mysql源是否安装成功
    yum repolist enabled | grep "mysql.*-community.*"
    • 安装MySQL
    yum install mysql-community-server
    • grep 找到 mysql 自动生成的 root 默认密码
    grep 'temporary password' /var/log/mysqld.log
    • 修改root本地登录密码
    shell> mysql -uroot -p
    mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourPassword9#'; 
    

    注意:mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位

    • 添加远程登录用户
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'YourPassword9#' WITH GRANT OPTION;
    • 配置默认编码为utf8
      修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置
      vim /etc/my.cnf
      [mysqld]
      character_set_server=utf8
      init_connect='SET NAMES utf8'

本文章首发在 Laravel China 社区