update: 2017-12-19 PHP7.2.0开始移除mcrypt模块,移除libmcrypt、libmcrypt-devel、mcrypt包和相应的PHP编译–enable-gd-native-ttf 和–with-mcrypt参数。
安装mcrypt参考:编译安装的PHP7.2如何安装mcrypt扩展每次配置环境的时候太麻烦了,要各种操作,今天写了这个一键安装脚本,此脚本只安装,nginx最新稳定版、mariadb-10.2.x最新稳定版、PHP可指定版本默认php-7.2.0,可以自定义网址,不需要带www,比如:kaifashuo.com,默认支持mysql远程连接,为了安全并没有在防火墙添加远程连接3306端口,默认开启22和80端口。
使用方法:
wget --no-check-certificate -O lnmp.sh https://raw.githubusercontent.com/shell/master/lnmp.sh
chmod +x lnmp.sh
bash lnmp.sh
脚本内容:
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#A tool to auto-compile & install Nginx+MySQL+PHP on Centos7 for laster stable version
#Web:https://www.kaifashuo.com Date:2017/12/9 version:1.0
#soft download dir
DIR=/usr/local/src
read -t 30 -p "Are you sure want to install LNMP,please input y/n : " lnmp
if [ "$lnmp" == "y" ]
then
echo -e "lnmp will be install" >> /usr/local/src/lnmp.log
else
exit
fi
read -t 30 -p "please input you website url default localhost : " websiteurl
if [ -z "$websiteurl" ]
then
websiteurl="localhost"
echo "website url default localhost"
fi
read -t 30 -p "please enter the mysql passwd.(Default password: root) : " mysqlrootpwd
if [ -z "$mysqlrootpwd" ]
then
mysqlrootpwd="root"
echo "MySQL root password:root"
fi
read -t 30 -p "please enter the PHP version.(Default version: 7.2.0) : " phpversion
if [ -z "$phpversion" ]
then
phpversion="7.2.0"
echo "PHP version:7.2.0"
fi
yum -y autoremove nginx*
yum -y autoremove httpd*
yum -y autoremove php*
yum -y autoremove mysql*
yum -y autoremove mariadb*
#delete mysql and nginx dir
rm -rf /var/lib/mysql/
rm -rf /etc/my.cnf
rm -rf /etc/nginx/
yum -y install epel-release.noarch
yum -y install firewalld
yum -y install wget gcc gcc-c++ make cmake perl autoconf automake libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel curl curl-devel openssl openssl-devel pcre pcre-devel libtool pcre-devel libaio-devel libaio bzip2-devel libcurl-devel gd-devel bison bison-devel libmcrypt libmcrypt-devel
yum update -y
cd $DIR
wget http://us2.php.net/distributions/php-$phpversion.tar.gz
tar xf php-$phpversion.tar.gz
echo ""
echo "===================nginx will be install ============================"
echo ""
sleep 5;
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum -y install nginx
cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak
cat > /etc/nginx/conf.d/default.conf
EOF
echo "================LNMP install is ok,now start LNMP and enable LNMP ======================="
echo ""
systemctl enable nginx.service
systemctl enable mariadb.service
systemctl enable php-fpm.service
/usr/bin/systemctl restart php-fpm
/usr/bin/systemctl restart nginx
/usr/bin/systemctl restart mysql
echo "================set firewalld default 80 22======================="
systemctl restart firewalld
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=22/tcp --permanent
firewall-cmd --reload
echo ""
echo "============LNMP install is ok, The path of some dirs:=============="
echo ""
echo "The path of some dirs:"
echo "mysql conf file : /etc/my.cnf"
echo "php install dir : /usr/local/php"
echo "php conf file : /usr/local/php/etc/php.ini"
echo "nginx conf file : /etc/nginx/nginx.conf and /etc/nginx/conf.d/"
echo "web dir : /usr/local/nginx/html"
echo "The mysql root passwd is : $mysqlrootpwd"
echo "please input http://ip/info.php, to checkout the lnmp is working!!!"
echo "Enjoy it !"
exit
还没有任何评论,你来说两句吧