说明
此脚本用于安装LNMP的运行环境,数据库选用mariadb数据库,除nginx外都使用的是Yum来完成安装
脚本
#!/bin/bash
setenforce 0
systemctl stop firewalld
mysql_install(){
yum -y install mariadb mariadb-server mariadb-devel &> /dev/null
systemctl start mariadb
systemctl enable mariadb &> /dev/null
ss -ntulp | grep mysql &> /dev/null
[ $? -eq 0 ] && echo "Mysql安装成功"
}
php_install(){
yum -y install php php-mysql php-fpm &> /dev/null
systemctl start php-fpm
systemctl enable php-fpm &> /dev/null
ss -ntulp | grep php-fpm &> /dev/null
[ $? -eq 0 ] && echo "php-fpm安装成功"
}
nginx_install(){
yum -y install gcc pcre-devel openssl-devel &> /dev/null
tar xf nginx-1.12.2.tar.gz -C /opt/ &> /dev/null
cd /opt/nginx-1.12.2/
./configure --with-http_ssl_module &> /dev/null
make &> /dev/null
make install &> /dev/null
/usr/local/nginx/sbin/nginx
ss -ntulp | grep nginx &> /dev/null
[ $? -eq 0 ] && echo "Nginx安装完成"
}
mysql_install
php_install
nginx_install
echo "完成安装"