zoukankan      html  css  js  c++  java
  • CentOS7.2使用yum配置LNMP环境

      一,安装系统查看

      

      二,yum安装nginx

      设置yum源

    rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
    

      安装nginx

    yum -y install nginx
    

      启动

    systemctl start nginx
    

      修改配置文件/etc/nginx/conf.d/default.conf设置支持php

    location ~ .php$ {
            root           /usr/share/nginx/html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

      三,yum安装MySQL5.7

      设置yum源

    name: rpm -ivh http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
    

      安装MySQL

    yum -y install mysql mysql-server
    

      启动MySQL

    systemctl start mysqld

      获取初始密码

    cat /var/log/mysqld.log |grep password
    

      使用初始密码登录并且修改密码

    mysql> SET PASSWORD = PASSWORD('Mysql123456!');
    

      

      四,yum安装php

      默认CentOS7.2的php版本为5.4这里设置安装php7

      设置yum源

    rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    

      安装

    yum -y install php70w php70w-fpm php70w-pdo php70w-mysql
    

      查看版本

    php -v
    php-fpm -v
    

      启动php-fpm

    php-fpm
    

      验证

      在目录/usr/share/nginx/html/下面新建两个文件

      test.php

    <?php
    phpinfo()
    ?>
    

      mysql.php

    <?php
        $mysqli = new mysqli("localhost", "root", "Mysql123456!");
        if(!$mysqli)  {
            echo"database error";
        }else{
            echo"MySQL successful";
        }
        $mysqli->close();
    ?>
    

  • 相关阅读:
    上传base64编码图片
    mysql
    当程序员老去 揭秘不为人知背后的辛酸故事
    Java中break的作用
    Random类
    使用dsoframer控件出现"Unable to display the inactive document. Click here to reactivate the document."的问题
    给IT新人的15个建议:苦逼程序员的辛酸反省与总结
    XML开发总结
    解决Office软件冲突问题
    PopupMenu控件的使用
  • 原文地址:https://www.cnblogs.com/minseo/p/8821948.html
Copyright © 2011-2022 走看看