美文网首页
腾讯云 centos 7.x 安装 lnmp 环境

腾讯云 centos 7.x 安装 lnmp 环境

作者: ling_1992 | 来源:发表于2018-06-14 11:57 被阅读0次

    1 将本地的yum源 切换为 阿里云yum源

    阿里云 镜像列表 ->找到centos

    1、备份
    [root]$ mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
    2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/
    // 选择 CentOS 7
    [root]$ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    或者
    [root]$ curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    3、之后
    [root]$ yum clean all 清除缓存
    [root]$ yum makecache生成缓存
    [root]$ yum -y update 更新整个仓库
    [root]$ init 1 重启机器
    

    2 安装php7.1X

    使用 Webtatic Yum Repository 安装 php 里面包含了所以最新版本的PHP
    CentOS/RHEL 7.x:

    [root]$ rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    //或者
    [root]$ yum install epel-release
    
    [root]$ rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
    [root]$ yum makecache 
    

    (企业版 Linux 附加软件包(epel)EPEL 官网)
    安装php71详细文档

    yum install -y mod_php71w  //main
    yum install -y php71w-cli  
    yum install -y php71w-fpm
    yum install -y php71w-pdo  //PHP PDO 扩展
    yum install -y php71w-mbstring  // Mbstring 扩展
    yum install -y php71w-mcrypt  // Mcrypt 扩展
    yum install -y php71w-gd // Gd扩展
    yum install -y php71w-mysqlnd // mysql 相关扩展
    yum install -y php71w-pecl-redis // redis 扩展
    

    3 安装nginx

    [root]$ yum install -y nginx 
    

    注解:单独安装最新版本: 安装nginx nginx官方下载页
    进入官网 找到download页的 Linux packages for stable version
    找到教程

    4 安装redis

    [root]$ yum install -y redis
    

    :安装最新版本 redis官网安装教程

    5 安装mysql5.7

    msyql 官网 download yum Respository 找到 yum Repository

    [root]$ rpm -Uvh https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
    [root]$ yum makecache
    [root]$ yum install -y mysql-community-server
    
    安装历史版本

    查看 repository 当前版本

    [root]$ yum repolist all | grep mysql
    Repository epel is listed more than once in the configuration
    Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
    mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community   disabled
    mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - disabled
    mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community   disabled
    mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - disabled
    !mysql-connectors-community/x86_64 MySQL Connectors Community    enabled:     42
    mysql-connectors-community-source  MySQL Connectors Community -  disabled
    !mysql-tools-community/x86_64      MySQL Tools Community         enabled:     53
    mysql-tools-community-source       MySQL Tools Community - Sourc disabled
    mysql-tools-preview/x86_64         MySQL Tools Preview           disabled
    mysql-tools-preview-source         MySQL Tools Preview - Source  disabled
    mysql55-community/x86_64           MySQL 5.5 Community Server    disabled
    mysql55-community-source           MySQL 5.5 Community Server -  disabled
    mysql56-community/x86_64           MySQL 5.6 Community Server    disabled
    mysql56-community-source           MySQL 5.6 Community Server -  disabled
    !mysql57-community/x86_64          MySQL 5.7 Community Server    enabled:    227
    mysql57-community-source           MySQL 5.7 Community Server -  disabled
    mysql80-community/x86_64           MySQL 8.0 Community Server    disabled
    mysql80-community-source           MySQL 8.0 Community Server -  disabled
    

    mysql57-community/x86_64 ------- enabled ---
    切换版本

    [root]$ yum-config-manager --disable mysql57-community
    [root]$ yum-config-manager --enable mysql56-community
    // yum-config-manager 指令 not found 执行下面
    [root]$ yum -y install yum-utils
    // 安装
    [root]$ yum install -y mysql-community-server
    

    启动软件

    在此之前需要开发端口

    1.设置腾讯云 中的 安全组 ,不然 端口全部开放 选择默认[放通22,80,443,3306端口和ICMP协议] 满足基本需求
    2.设置firewall

    [root]$ firewall-cmd --add-port=80/tcp --permanent
    [root]$ firewall-cmd --add-port=3306/tcp --permanent
    .......
    [root]$ firewall-cmd --reload
    

    1.nginx [nginx:nginx]

    [root]$ systemctl start nginx
    

    使用默认配置文件 /etc/nginx/nginx.conf 即可 如果想深入了解: (配置详细说明)
    修改 /etc/nginx/conf.d/default.conf 文件 把php文件交给php-fpm处理

    server {
        .....
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
        .....
    }
    

    修改完之后 需要 restart nginx服务

    2.php-fpm [apache:apache]

    [root]$ systemctl start php-fpm
    

    3. MySQL

    [root]$ systemctl start mysqld 
    

    修改mysql登录密码:

    //# 找到临时密码
    [root]$  grep "password" /var/log/mysqld.log  
    2018-03-15T02:35:02.355088Z 1 [Note] A temporary password is generated for root@localhost: LDl16K=kbIrm
    //#使用临时密码登录并修改密码
    [mysql> set password = password('**********'); #密码需要有大小写字母符号和数字
    [mysql>  flush privileges; #刷新
    

    修改字符集编码
    编辑 /etc/my.cnf
    在 [mysqld] 下添加 character-set-server=utf8 即可

    4 Redis

    [root]$ redis-server  /etc/redis.conf -daemonize
    

    相关文章

      网友评论

          本文标题:腾讯云 centos 7.x 安装 lnmp 环境

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