#!/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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通