#!/bin/bash
# mount and install dependence bag
mount /dev/cdrom /mnt
cd /mnt/Server
rpm -ivh gcc-4.1.2-44.e15.i386.rpm glibc-devel-2.5-34.i386.rpm glibc-
headers-2.5-34.i386.rpm kernel-headers-2.6.18-128.e15.i386.rpm
libgomp-4.3.2-7.e15.i386.rpm
rpm -ivh gcc-c++-4.1.2-44.e15.i386.rpm libstdc++-devel-4.1.2-
44.e15.i386.rpm
rpm -ivh ncurses-devel-5.5-24.20060715.i386.rpm libxm12-devel-2.6.26-
2.1.2.7.i386.rpm zlib-devel-1.2.3-3.i386.rpm
lamp_tar = /usr/software
lamp_down = /download
if [ ! -d /download];then
mkdir /download
fi
#download lamp packet
wget http://labs.renren.com/apache-mirror//httpd/httpd-2.2.21.tar.gz
-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
tar zxvf
if [ ! -d /usr/software];then
mkdir /usr/software
fi
# uncompress file
cd $lamp_down
for i in $lamp_down/*.tar.gz
do
tar fvxz $i -C $lamp_tar
done
for i in $lamp_down/*.tar.bz2
do
tar xjvf $i -C $lamp_tar
done
# install apache
mkdir /usr/local/apache
cd $lamp_tar/httpd.2.2.21/
./configure --prefix=/usr/local/apache --enable-so --enable-rewrite
--enable-vhost-alias -enable-http enable-static-htpasswd
make && make install
service httpd start
chkconfig httpd on
# install mysql
mkdir /usr/local/mysql
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
# 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/mysqld start
chkconfig mysqld on
# install PHP
mkdir /usr/local/php
cd $lamp_tar/php-5.3.8
./configure --with-apxs2=/usr/local/apache/bin/apxs --with-
mysql=/usr/local/mysql/
make && make install
#copy file and write to log
cp $lamp_tar/php-5.3.8/php.ini-production /usr/local/php5/lib/php.ini
echo "application/x-httpd-php php" >>
/usr/local/apache2/conf/httpd.conf
#edit test.php
touch $htdocs/test.php
echo " <? phpinfo();?>" > $htdocs/test.php
# restart apache
/usr/local/apache/bin/apachectl restart
echo "/usr/local/apache/bin/apachectl start" >>/etc/rc.local
转载于:https://blog.51cto.com/hyrieshu/1073617