zoukankan      html  css  js  c++  java
  • centos7 yum安装lnmp环境

    #!/bin/bash
    MYSQL_PASSWD="Ab123456!"
    
    function yum_update() {
        cd /etc/yum.repos.d/
        mkdir bak && cp ./*.repo bak
        yum install -y wget 
        wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
        wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
        yum install -y epel-release lrzsz zip unzip git gcc gcc-c++ yum-utils tmux screen net-tools vim tree telnet rsync harfbuzz
    }
    
    function install_nginx() {
        yum -y install nginx
        systemctl start nginx
        systemctl enable nginx
    }
    
    function install_mysql(){
        cat >/etc/yum.repos.d/mysql-community.repo <<-EOF
    [mysql-connectors-community]
    name=MySQL Connectors Community
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-connectors-community-el7-$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
    
    [mysql-tools-community]
    name=MySQL Tools Community
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-tools-community-el7-$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
    
    [mysql-5.6-community]
    name=MySQL 5.6 Community Server
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.6-community-el7-$basearch/
    enabled=0
    gpgcheck=1
    gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
    
    [mysql-5.7-community]
    name=MySQL 5.7 Community Server
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
    
    [mysql-8.0-community]
    name=MySQL 8.0 Community Server
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-8.0-community-el7-$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql
    EOF
    
        yum list installed | grep -w yum-utils &>/dev/null
        [ $? -ne 0 ] && yum install yum-utils -y
        yum-config-manager --disable mysql-8.0-community
        yum-config-manager --enable mysql-5.7-community
    
        yum install -y mysql-community-server
        systemctl start mysqld
        systemctl enable mysqld
    
        passwd=$(grep 'temporary password' /var/log/mysqld.log|tail -n 1|awk '{print $NF}')
        mysql --connect-expired-password -uroot -p${passwd} <<-EOF
    ALTER USER root@'localhost' IDENTIFIED BY '${MYSQL_PASSWD}';
    flush privileges;
    EOF
    
        sleep 1
        systemctl restart mysqld
    }
    
    function install_php(){
        rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-7.rpm
        yum install -y --enablerepo=remi --enablerepo=remi-php56 php php-fpm php-opcache php-devel php-mbstring 
    php-mcrypt php-mysqlnd  php-pecl-xdebug php-pecl-xhprof php-gd php-bcmath
        systemctl start php-fpm
        systemctl enable php-fpm
    
    }
    
    function main(){
        yum_update
        install_nginx
        install_mysql
        install_php
    }
    
    main
    
  • 相关阅读:
    VS2012快捷操作功能
    SQL Union和SQL Union All用法
    安装sql server 2008 R2出现 创建usersettings/microsoft.sqlserver.configuration.landingpage.properties.setter
    编码的来历和使用 utf-8 和GB2312比较
    Java内存机制,内存地址
    spring
    使用CMD建立指定格式的文件
    在命令提示符窗口下(cmd)使用指令操作并编译java代码,运行java编译代码
    匿名内部类的使用总结
    网页中插入FLASH(swf文件)的html代码
  • 原文地址:https://www.cnblogs.com/51fly/p/14688448.html
Copyright © 2011-2022 走看看