• Centos7.2 下搭建LNMP环境(终极版)Yum安装


    
    

    PHP7.1+Nginx+MySQL5.7

    安装PHP

    //安装源只要遇到选择的全是Y

    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

    //安装PHP和PHP-FPM

    yum install php71w php71w-cli php71w-fpm  

    //安装相关扩展

    yum install php71w-mbstring php71w-common
    yum install php71w-gd php71w-mcrypt 
    yum install php71w-mysql php71w-xml 
    yum install php71w-soap php71w-xmlrpc

     只要显示版本那就OK!

     安装Nginx

    //安装nginx
    yum install nginx  
    //启动nginx
    systemctl start nginx  
    //使用systemctl设置开机启动
    systemctl enable nginx  

     Nginx 安装完成

    如果打不开就关闭防火墙

    firewall-cmd --permanent --zone=public --add-service=http  
    firewall-cmd --reload  

    安装Mysql

    //安装MySQL源
    yum install https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
    //安装MySQL
    yum install mysql-community-server
    //启动MySQL
    systemctl start mysqld  
    //设置开机启动
    systemctl enable mysqld
     grep 'temporary password' /var/log/mysqld.log   获取mysql5.7的默认密码

    然后登陆

    mysql -uroot -p

     然后修改密码的强度

    set global validate_password_policy=0; 
    set global validate_password_length=1;

    然后最后执行修改操作,把密码修改为root
    ALTER USER 'root'@'localhost' IDENTIFIED BY 'root;
    然后exit;退出重新登陆就完成了

    设置Nginx和PHP-FPM

    我已经安装好需要程序,要想PHP请求被Nginx接收并转交给PHP-FPM再由PHP解释器执行返回结果,还需要做一些配置。

    //启动PHP-FPM
    systemctl start php-fpm  
    //设置开机启动
    systemctl enable php-fpm  
    server {  
      listen        80;
      server_name   zkt.devnet;
      root          /data/www/zkt.devnet;
      index         index.php index.html;
    
      location / {
        try_files $uri $uri/ /index.php?$query_string;
      }
    
      location ~ .php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      }
    }
    
    //重启Nginx
    systemctl restart nginx
    //在/data/www/zkt.devnet增加phpinfo.php文件写入以下内容
    <?php  
      phpinfo();

     

    就OK了

    原文链接

    http://www.zkt.name/centos-7-an-zhuang-phpkai-fa-huan-jing/

    感谢这位大师

  • 相关阅读:
    自定义vue必填验证指令
    福珑2日常存活策略
    树莓派系统安装和配置 WiringPi
    代码实现RabbitMQ死信队列的创建
    博客已经搬家
    浅谈PHP序列化与反序列化
    prometheus监控golang服务实践
    ETCD核心机制解析
    N1BOOK 记录
    利用Ubuntu虚拟机制作F2FS文件系统镜像
  • 原文地址:https://www.cnblogs.com/wlphp/p/8584262.html
Copyright © 2020-2023  润新知