本篇内容介绍了“Linux中怎么一键LAMP安装脚本”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
创建脚本安装目录,并创建bash文件
[root@aaa~]mkdir /tools[root@aaa~]cd /tools[root@aaa~]touch lamp.sh
编写脚本
#!/bin/bash#The author is wanghuachao.#This is the lamp installation script.---独自莫凭栏,无限关山,别时容易去时难。#QQ:757844766 Mail:757844766@qq.com. /etc/init.d/functionsapache(){cd /toolsecho "********************************************************"echo "*****************正在下载apache及相关软件***************"echo "********************************************************"if [ ! -f /tools/httpd-2.4.33.tar.gz ]fiif [ ! -f /tools/apr-1.5.0.tar.gz ]then wget -q http://archive.apache.org/dist/apr/apr-1.5.0.tar.gzfiif [ ! -f /tools/apr-util-1.5.4.tar.gz ]echo "下载完成。"cd /toolstar -zxf apr-1.5.0.tar.gzcd apr-1.5.0./configure --prefix=/usr/local/apr/make && make installcd /toolstar -zxf apr-util-1.5.4.tar.gzcd apr-util-1.5.4./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/make && make installcd /toolstar zxvf httpd-2.4.33.tar.gzcd httpd-2.4.33mysql(){cd /toolsecho "*****************************************************"echo "*****************安装编译数据库mysql******************"echo "*****************************************************"if [ ! -f mysql-5.6.39.tar.gz ];thenwget http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.6/mysql-5.6.39.tar.gzfitar zxvf mysql-5.6.39.tar.gzcd mysql-5.6.39makeecho $?sleep 20make installecho $?sleep 20chown -R mysql:mysql /usr/local/mysqlecho $?cd /usr/local/mysql/echo $?/bin/cp support-files/mysql.server /etc/init.d/mysqlecho "*****************************************************"cd /usr/local/mysql#mysql -e "update mysql.user set password=PASSWORD('123456')where user='root';"#mysql -e "flush privileges;"#echo "*****************************************************"echo "*****************数据库设置完成。********************"echo "*****************************************************"}PHP(){cd /toolswget http://cn2.php.net/distributions/php-7.1.1.tar.gztar zxvf php-7.1.1.tar.gzcd php-7.1.1make && make installcp php.ini-development /usr/local/php71/etc/php.iniecho "*****************************************************"echo "*****************PHP安装完成********************"echo "*****************************************************"echo "Addtype application/x-httpd-php .php" >>/usr/local/apache24/conf/httpd.confpkill httpd/usr/local/apache24/bin/apachectl start}emlog(){echo "*****************************************************"echo "*****************安装 emlog网站********************"echo "*****************************************************"cd /shellunzip emlog_v5.3.1.zipcd emlogcd src/cp * -R /usr/local/apache24/htdocs/rm /usr/local/apache24/htdocs/index.htmlecho "*****************************************************"echo "*****************网站安装完成。********************"echo "*****************************************************"}function menu(){cat [EOF中括号改成while truedoread -p "输入指令:" sscase $ss in 1) apache ;; 2) mysql ;; 3) PHP ;; 4) emlog ;; q) exit ;;esacdone
如此lamp一键安装就完成了
“Linux中怎么一键LAMP安装脚本”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注编程网网站,小编将为大家输出更多高质量的实用文章!