#!/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
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/194322.html
標籤:其他
