ITPub博客

首页 > 应用开发 > > LAMP自动化安装脚本

LAMP自动化安装脚本

作者:lakefront 时间:2019-09-09 15:56:50 0 删除 编辑

前辈和我说,刚开始一个个服务慢慢安装,以后要写自动安装脚步,不断学习!

仿他人改了一个脚本,按照自己的习惯,呵呵 

#!/bin/bash

#version:2011-9-16

#create by roc

#dis: this is used to auto install lamp.

#rocbg

lamp_down=/usr/local/src/tarbag

lamp_tar=/usr/local/src/software

lamp_log=/tmp/lamp_install.log

echo "####################`date` #################" >> $lamp_log

ip=`ifconfig eth0 | grep Bcast | awk -F ":" '{print $2}' | cut -d " " -f 1`

echo ip:$ip >> $lamp_log

if [ ! -d /usr/local/src/tarbag ];then 

mkdir /usr/local/src/tarbag 

fi 

#download lamp packet 

wget http://labs.renren.com/apache-mirror//httpd/httpd-2.2.21.tar.gz -P $lamp_down 

wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.6.tar.gz -P $lamp_down 

wget http://www.boutell.com/gd/http/gd-2.0.33.tar.gz  -P $lamp_down 

wget http://ijg.org/files/jpegsrc.v8c.tar.gz -P $lamp_down 

wget http://sourceforge.net/projects/libpng/files/libpng15/1.5.4/libpng-1.5.4.tar.gz/download -P $lamp_down 

wget http://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.5.3-m3.tar.gz -P $lamp_down 

wget http://cn2.php.net/distributions/php-5.3.8.tar.bz2 -P $lamp_down 

if [ ! -d /usr/local/src/software ];then 

    mkdir /usr/local/src/software

fi 

#uncompress file 

cd   $lamp_down

for i in $lamp_down/*.tar.gz 

do 

tar -xzvf $i -C $lamp_tar 

done 

 

for i in $lamp_down/*.tar.bz2 

do 

    tar -xjvf $i -C $lamp_tar

done 

#Apache install 

echo "Apache install start!" >>$lamp_log

 

cd $lamp_tar/httpd-2.2.21/ 

./configure --prefix=/usr/local/apache2 --enable-so  \ 

--enable-rewrite --enable-vhost-alias --enable-http \ 

--enable-static-htpasswd 

sleep 10 

make && make install 

sleep 8 

ln  -s /usr/local/apache2/bin/apachectl /bin/apachectl 

 

#modity ServerName DirectoryIndex options 

sed -i '292c\ServerName $ip:80' /usr/local/apache2/conf/httpd.conf 

sed -i '394c\DirectoryIndex index.php index.html index.html.var' /usr/local/apache2/conf/httpd.conf 

 

#test apache configure 

/bin/apachectl -t >> $lamp_log 

echo "`date` Apache is Installed"  >> $lamp_log 

#sed -i '6c\SELINUX=disabled' /etc/selinux/config 

 

/bin/apachectl start && echo "`date` Apache is started Good!" >> $lamp_log 

echo "`date` Please modify httpd.conf ServerName Option" >> $lamp_log 

#Freetype Install 

echo "`date` Freetype install start" >> $lamp_log 

cd $lamp_tar/freetype-2.4.6/ 

./configure --prefix=/usr/local/freetype 

make && make install 

sleep 5 

echo "`date` Freetype is  installed" >> $lamp_log 

sleep 10 

 

#JPEG install 

echo "`date` jpeg install start" >> $lamp_log 

cd $lamp_tar/jpeg-8

./configure --prefix=/usr/local/jpeg7 

make && make install 

echo "`date` jpeg is installed" >> $lamp_log 

sleep 8 

 

#libpng Install 

echo "`date` libpng  install start" >> $lamp_log 

cd $lamp_tar/libpng-1.5.4 

./configure --prefix=/usr/local/libpng 

make && make install 

echo "`date`libpng is installed" >> $lamp_log 

sleep 10 

 

#gd install 

echo "`date`gd start install" 

cd $lamp_tar/gd-2.0.33 

./configure --prefix=/usr/local/gd \ 

--with-png=/usr/local/libpng --with-freetype=/usr/local/freetype \ 

--with-jpeg=/usr/local/jpeg7 

#modify gd_png.c 

sed -i '/png.h/d' gd_png.c 

sed -i '15c\#include "/usr/local/libpng/include/png.h" ' gd_png.c 

 

make && make install 

echo "`date` gd is installed" >> $lamp_log 

#Mysql Install 

 

useradd mysql  && echo "`date` user mysql added" >> $lamp_log 

 

cd $lamp_tar/mysql-5.5.3-m3

./configure  --prefix=/usr/local/mysql  --datadir=/mydata --with-charset=utf8 --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-ssl --with-embedded-server --enable-local-infile --enable-assembler --with-plugins=innobase  --with-plugins=partition

 

make && make install 

 

echo "`date` mysql is installed " >> $lamp_log 

#about configure file 

cp $lamp_tar/mysql-5.5.3-m3 

cp support-files/my-large.cnf /etc/my.cnf 

chown -R mysql.mysql /usr/local/mysql 

 

#pre databases 

/usr/local/mysql/bin/mysql_install_db --user=mysql 

#service file 

cp $lamp_tar/mysql-5.5.3-m3/support-files/mysql.server /etc/init.d/mysql 

chmod 755 /etc/init.d/mysql

#start mysql 

/etc/init.d/mysql start  && echo "`date` mysql service is ready" >> $lamp_log 

 

 

#PHP install 

echo "`date` php-5.3.8 start install " >> $lamp_log 

cd $lamp_tar/php-5.3.8 

./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-jpeg-dir=/usr/local/jpeg7/ --with-gd=/usr/local/gd/ --with-png-dir=/usr/local/libpng/ --with-freetype-dir=/usr/local/freetype/ --enable-mbregex --with-mysql=/usr/local/mysql/ --with-pdo-mysql=/usr/local/mysql/ 

make && make install 

 

#copy file and write to log 

cp $lamp_tar/php-5.3.8/php.ini-recommended /usr/local/php5/lib/php.ini && \ 

echo "`date` php.ini file is copyed to /usr/local/php5/lib/" >> $lamp_log 

echo "application/x-httpd-php  php" >> /usr/local/apache2/conf/mime.types 

 

#edit test.php 

touch $htdocs/test.php 

cat >> $htdocs/test.php << CHENG 

phpinfo(); 

?> 

echo "Go to http://$ip/test.php" >> $lamp_log 

echo "Mysql port 3306 and socket_file is  /tmp/mysql.socket" >> $lamp_log 

echo " user=root  paswd=null" >> $lamp_log 

echo "##########end################" >> $lamp_log 

cat /usr/local/apache2/build/config.nice >> $lamp_log 

/usr/local/php/bin/php -i |grep configure >> $lamp_log 

cat /usr/local/mysql/bin/mysqlbug|grep configure >> $lamp_log

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2491/viewspace-3130511/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-08-05

  • 博文量
    99
  • 访问量
    625