美文网首页
CentOS 7搭建LNMP环境(mysql 5.7、php 7

CentOS 7搭建LNMP环境(mysql 5.7、php 7

作者: 魔思科技 | 来源:发表于2018-12-03 19:46 被阅读22次

    一、搭建前的准备

    1. 更新系统软件yum:yum update

    二、安装nginx

    1. 安装nginx最新源
    yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
    yum repolist enabled | grep "nginx*" 
    
    1. 安装nginx:yum -y install nginx
    2. 启动nginx:systemctl start nginx
    3. 设置nginx服务器开机自启动:systemctl enable nginx.service
      检查开机自动是否设置成功:systemctl list-dependencies | grep nginx

    三、安装mysql5.7

    1. 安装mysql源
    yum -y localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
    yum repolist enabled | grep "mysql.*-community.*"
    
    1. 安装mysql:yum -y install mysql-community-server install mysql-community-devel
    2. 启动mysql:systemctl start mysqld
      检查mysql启动是否正常:systemctl status mysqld或者ps -ef | grep mysql
    3. 设置mysqld服务开机自启动:systemctl enable mysqld.service
      检查mysqld开机自启动是否设置成功:systemctl list-dependencies | grep mysqld
    4. 修改MySQL密码(5.7以上)
      <1> 查看密码:grep 'temporary password' /var/log/mysqld.log
      <2> 登录MySql并修改root密码:
    mysql -uroot -p
    # 修改validate_password_policy参数的值
    set global validate_password_policy=0;
    # 修改密码的长度
    set global validate_password_length=1;
    ALTER USER 'root'@'localhost' IDENTIFIED BY 'new psd';
    

    四、安装php7.2

    1. 安装php源
    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 repolist enabled | grep "webtatic*"

    1. 安装php扩展源
    yum -y install php72w php72w-fpm php72w-mbstring php72w-common php72w-gd php72w-mcrypt php72w-mysql php72w-xml php72w-cli php72w-devel php72w-pecl-memcached php72w-pecl-redis php72w-opcache php72w-mysqlnd
    
    1. 验证php7.2.x和扩展是否安装成功
      验证php是否安装成功:php -v
      验证对应的扩展是否安装成功:php -m
    2. 启动php-fpm:systemctl start php-fpm
      检查启动是否成功:systemctl status php-fpm
    3. 设置开机自启动:systemctl enable php-fpm.service
    4. 检查开机自启动是否设置成功
    systemctl list-dependencies | grep php-fpm
    ps -ef | grep php-fpm
    

    备注:设置网站路径时,nginx一定要有路径下的全部权限

    相关文章

      网友评论

          本文标题:CentOS 7搭建LNMP环境(mysql 5.7、php 7

          本文链接:https://www.haomeiwen.com/subject/usgjiftx.html