#!/bin/bash
init(){
systemctl stop firewalld
setenforce 0
yum -y install wget
if [ ! -e /etc/yum.repos.d/nginx.repo ]; then
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
fi
}
nginx_install(){
if [ -d /etc/nginx ]; then
echo "nginx 已经存在!"
else
yum -y install nginx
systemctl enable nginx
netstat -lptnu|grep 80
if [ $? -eq 0 ]; then
echo "nginx 服务已经运行!"
else
systemctl start nginx
fi
fi
}
db_install(){
if [ -d /var/lib/mysql ]; then
echo "mysql 已经存在"
else
yum -y install mariadb mariadb-server
systemctl enable mariadb
netstat -lptnu|grep 3306
if [ $? -eq 0 ]; then
echo "mariadb 服务已经运行!"
else
systemctl start mariadb
fi #mysql 相关操作:
mysql -e "show databases;"|grep -w wordpress
if [ $? -eq 0 ]; then
echo "wordpress 已经存在"
else
mysql -e "create database wordpress;"
fi
mysql -e "grant all on *.* to 'wordpress'@'localhost' IDENTIFIED by '123456';"
mysql -e "flush privileges;"
fi}php_install(){
netstat -lptnu|grep 9000
if [ $? -eq 0 ]; then
echo "php-fpm 已经正常运行"
else
yum -y install php php-fpm php-mysql
systemctl enable php-fpm
systemctl start php-fpm
fi
}
main(){
init
nginx_install
db_install
php_install
}
main
shell(一键部署wordpress)
猜你喜欢
转载自blog.csdn.net/fenghumen/article/details/109278956
今日推荐
周排行