导读 | 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/functions apache(){ cd /tools echo "********************************************************" echo "*****************正在下载apache及相关软件***************" echo "********************************************************" if [ ! -f /tools/httpd-2.4.33.tar.gz ] fi if [ ! -f /tools/apr-1.5.0.tar.gz ] then wget -q //archive.apache.org/dist/apr/apr-1.5.0.tar.gz fi if [ ! -f /tools/apr-util-1.5.4.tar.gz ] echo "下载完成。" cd /tools tar -zxf apr-1.5.0.tar.gz cd apr-1.5.0 ./configure --prefix=/usr/local/apr/ make && make install cd /tools tar -zxf apr-util-1.5.4.tar.gz cd apr-util-1.5.4 ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/ make && make install cd /tools tar zxvf httpd-2.4.33.tar.gz cd httpd-2.4.33 mysql(){ cd /tools echo "*****************************************************" echo "*****************安装编译数据库mysql******************" echo "*****************************************************" if [ ! -f mysql-5.6.39.tar.gz ];then wget //ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.6/mysql-5.6.39.tar.gz fi tar zxvf mysql-5.6.39.tar.gz cd mysql-5.6.39 make echo $? sleep 20 make install echo $? sleep 20 chown -R mysql:mysql /usr/local/mysql echo $? cd /usr/local/mysql/ echo $? /bin/cp support-files/mysql.server /etc/init.d/mysql echo "*****************************************************" 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 /tools wget //cn2.php.net/distributions/php-7.1.1.tar.gz tar zxvf php-7.1.1.tar.gz cd php-7.1.1 make && make install cp php.ini-development /usr/local/php71/etc/php.ini echo "*****************************************************" echo "*****************PHP安装完成********************" echo "*****************************************************" echo "Addtype application/x-httpd-php .php" >>/usr/local/apache24/conf/httpd.conf pkill httpd /usr/local/apache24/bin/apachectl start } emlog(){ echo "*****************************************************" echo "*****************安装 emlog网站********************" echo "*****************************************************" cd / unzip emlog_v5.3.1.zip cd emlog cd src/ cp * -R /usr/local/apache24/htdocs/ rm /usr/local/apache24/htdocs/index.html echo "*****************************************************" echo "*****************网站安装完成。********************" echo "*****************************************************" }
function menu(){ cat [EOF中括号改成<< 1.安装Apache. 2.安装Mysql数据库. 3.安装PHP. 4.安装网站. q.退出. EOF } menu while true do read -p "输入指令:" ss case $ss in 1) apache ;; 2) mysql ;; 3) PHP ;; 4) emlog ;; q) exit ;; esac done
如此lamp一键安装就完成了
本文原创地址://q13zd.cn/lamp.html编辑:王华超,审核员:逄增宝