|
#!/bin/sh
########################################################
## Title: AutoInstallation Script ##
## Version: 1.5 ##
## Date: 2006-1-16 ##
## Author: yulong ##
## Email: yulong8404@hotmail.com ##
## License: General Public License (GPL) ##
## Copyright(c) 2005-2006, yulong All Rights Reserved ##
########################################################
#软件安装前请您花费一点时间阅读以下内容:
#
#1、安装包默认放在/usr/local/src/ 目录下面,当然你也可以根据自己的需要更改INSTALL=/usr/local/src 路径
#2、软件安装时默认安装在/usr/local/目录下面,不建议修改
#3、安装mysql的时候会要求输入mysql密码,密码配置文件保存在usr/local/mysql/passwd.root 文件中,建议安装完以后删除此文件
#4、本脚本的FTP软件是基于MYSQL验证,所以在自动安装过程中FTP初始ID为purftpd,密码为123456。
# 如果不想基于MYSQL验证,请注销FTP软件安装部分,或对部分内容进行修改。
#5、如果更改了FTP默认用户名和密码,请修改本脚本合集包中的pureftp.config.php和pureftpd-mysql.conf 配置文件中的用户名和密码
#6、软件安装完成以后无需重启任何服务,即可使用
#
#########################################################
#
# 需要用到的软件包下载地址
#
# apache
# http://www.apache.org/dist/httpd/
# php
# http://cn2.php.net/get/php-4.4.1.tar.gz/from/cn.php.net/mirror
# mysql
# http://www.mysql.com/
# pureftpd
# http://www.pureftpd.org/
# pureftp_php_manager
# http://www.solariz.de/files/pureftpd_php_manager.zip
# freetype
# ftp://ftp.freetype.org/freetype/freetype2/ftdocs-2.1.10.tar.gz
# zlib
# http://www.zlib.org
# jpeg
# http://www.ijg.org/
# gd
# http://www.gd.org
# libpng
# http://www.libpng.org/pub/png/
# rrdtool
# http://ee-staff.ethz.ch/~oetiker/webtools/rrdtool/
#
#
###################################################
#安装包的存放位置,须放在同一目录下
INSTALL=/usr/local/src
#软件下载地址
HTTP=http://www.lxgchina.com
#定义各种软件包的版本号,方便以后升级更改软件包版本
FreetypeVersion="2.1.10"
ZlibVersion="1.2.1"
JpegVersion="v6b"
GdVersion="2.0.23"
RrdToolVersion="1.0.49"
LibpngVersion="1.2.5"
ApacheVersion="1.3.34"
PHPVersion="4.4.1"
MySQLVersion="4.0.26"
PureftpdVersion="1.0.20"
###################################################
#检查GD包是否存在,存在继续,不存在弹出提示,并退出安装
echo -ne "\33[32m\33[5m\33[1m Back-check GD whether of not in existence \33[0m\n"
[ -f $INSTALL/gd-$GdVersion.tar.gz ]
if [ $? -eq 1 ]; then
echo -ne "\33[35m\33[5m\33[1m There is no GD packet \33[0m\n"
wget $HTTP/gd-2.0.23.tar.gz
exit 1
fi
#检查Zlib包是否存在,存在继续,不存在弹出提示,并退出安装
echo -ne "\33[32m\33[5m\33[1m Back-check Zlib whether of not in existence \33[0m\n"
[ -f $INSTALL/zlib-$ZlibVersion.tar.gz]
if [ $? -eq 1 ]; then
echo -ne "\33[35m\33[5m\33[1m There is no Zlib packet \33[0m\n"
wget $HTTP/zlib-1.2.1.tar.gz
exit 1
fi
#检查Freetype包是否存在,存在继续,不存在弹出提示,并退出安装
echo -ne "\33[32m\33[5m\33[1m Back-check Freetype whether of not in existence \33[0m\n"
[ -f $INSTALL/freetype-$FreetypeVersion.tar.gz ]
if [ $? -eq 1 ]; then
echo -ne "\33[35m\33[5m\33[1m There is no Freetype packet \33[0m\n"
wget $HTTP/freetype-2.1.10.tar.gz
exit 1
fi
#检查Jpeg包是否存在,存在继续,不存在弹出提示,并退出安装
echo -ne "\33[32m\33[5m\33[1m Back-check Jpeg whether of not is existence \33[0m\n"
[ -f $INSTALL/jpegsrc.$JpegVersion.tar.gz]
if [ $? -eq 1 ]; then
echo -ne "\33[35m\33[5m\33[1m There is no Jpeg packet \33[0m\n"
wget $HTTP/jpegsrc.v6b.tar.gz
exit 1
fi
#检查rrdtool包是否存在,存在继续,不存在弹出提示,并退出安装
echo -ne "\33[32m\33[5m\33[1m Back-check RrdTool whether of not in existence \33[0m\n"
[ -f $INSTALL/rrdtool-$RrdToolVersion.tar.gz ]
if [ $? -eq 1 ]; then
echo -ne "\33[35m\33[5m\33[1m There is no RrdTool packet \33[0m\n"
wget $HTTP/rrdtool-1.0.49.tar.gz
exit 1
fi
#检查Libpng包是否存在,存在继续,不存在弹出提示,并退出安装
echo -ne "\33[32m\33[5m\33[1m Back-check Libpng whether of not in existence \33[0m\n"
[ -f $INSTALL/libpng-$LibpngVersion.tar.gz ]
if [ $? -eq 1 ]; then
echo -ne "\33[35m\33[5m\33[1m There is no Libpng packet \33[0m\n"
wget $HTTP/libpng-1.2.5.tar.gz
exit 1
fi
#检查apache包是否存在,存在继续,不存在弹出提示,并退出安装
echo -ne "\33[32m\33[5m\33[1m Back-check apache whether of not in existence \33[0m\n"
[ -f $INSTALL/apache_$ApacheVersion.tar.gz ]
if [ $? -eq 1 ]; then
echo -ne "\33[35m\33[5m\33[1m There is no apache packet \33[0m\n"
wget $HTTP/apache_1.3.34.tar.gz
exit 1
fi
#检查php包是否存在,存在继续,不存在弹出提示,并退出安装
echo -ne "\33[32m\33[5m\33[1m Back-check php whether of not in existence \33[0m\n"
[ -f $INSTALL/php-$PHPVersion.tar.gz ]
if [ $? -eq 1 ]; then
echo -ne "\33[35m\33[5m\33[1m There is no php packet \33[0m\n"
wget $HTTP/php-4.4.1.tar.gz
exit 1
fi
#检查mysql包是否存在,存在继续,不存在弹出提示,并退出安装
echo -ne "\33[32m\33[5m\33[1m Back-check mysql whether of not in existence \33[0m\n"
[ -f $INSTALL/mysql-$MySQLVersion.tar.gz ]
if [ $? -eq 1 ]; then
echo -ne "\33[35m\33[5m\33[1m There is no mysql packet \33[0m\n"
wget $HTTP/mysql-4.0.26.tar.gz
exit 1
fi
#检查pureftpd包是否存在,存在继续,不存在弹出提示,并退出安装
echo -ne "\33[32m\33[5m\33[1m Back-check pureftpd whether of not in existence \33[0m\n"
[ -f $INSTALL/pure-ftpd-$PureftpdVersion.tar.gz ]
if [ $? -eq 1 ]; then
echo -ne "\33[35m\33[5m\33[1m There is no pureftpd packet \33[0m\n"
wget $HTTP/pure-ftpd-1.0.20.tar.gz
wget $HTTP/pureftpd_php_manager.zip
exit 1
fi
###################################################
#解压缩软件包
tar zxvf freetype-$FreetypeVersion.tar.gz
tar zxvf gd-$GdVersion.tar.gz
tar zxvf zlib-$ZlibVersion.tar.gz
tar zxvf jpegsrc.$JpegVersion.tar.gz
tar zxvf rrdtool-$RrdToolVersion.tar.gz
tar zxvf libpng-$LibpngVersion.tar.gz
tar zxvf apache_$ApacheVersion.tar.gz
tar zxvf php-$PHPVersion.tar.gz
tar zxvf mysql-$MySQLVersion.tar.gz
tar zxvf pure-ftpd-$PureftpdVersion.tar.gz
#开始安装freetype软件包
echo -ne "\33[32m\33[5m\33[1m Configure And Install Freetype \33[0m"
sleep 10
cd freetype-$FreetypeVersion
./configure --prefix=/usr/local/freetype &&
make &&
make install &&
#开始安装Zlib软件包
echo -ne "\33[32m\33[5m\33[1m Configure And Install Zlib \33[0m"
sleep 10
cd ..
cd zlib-$ZlibVersion
./configure --prefix=/usr/local/zlib &&
make &&
make install &&
#开始安装Jpeg软件包
echo -ne "\33[32m\33[5m\33[1m Configure And Install Jpeg \33[0m"
sleep 10
cd ..
cd jpeg-6b
./configure --prefix=/usr/local/jpeg --enable-shared --enable-static &&
make &&
mkdir -p /usr/local/jpeg/include
mkdir /usr/local/jpeg/lib
mkdir /usr/local/jpeg/bin
mkdir -p /usr/local/jpeg/man/man1
make install &&
#开始安装gd软件包
echo -ne "\33[32m\33[5m\33[1m Configure And Instal Gd \33[0m"
sleep 10
cd ..
cd gd-$GdVersion
./configure --prefix=/usr/local/gd \
--with-freetype=/usr/local/freetype \
--with-jpeg=/usr/local/jpeg &&
make &&
make install &&
#开始安装rrdtool软件包
echo -ne "\33[32m\33[5m\33[1m Configure And Install RrdTool \33[0m"
sleep 10
cd ..
cd rrdtool-$RrdToolVersion
./configure --prefix=/usr/local/rrdtool &&
make &&
make install &&
#开始安装libpng软件包
echo -ne "\33[32m\33[5m\33[1m Configure And Install Libpng \33[0m"
sleep 10
cd ..
cd libpng-$LibpngVersion
cp scripts/makefile.linux makefile
make &&
make install &&
#开始安装apache软件包
echo -ne "\33[32m\33[5m\33[1m Configure And Install Apache \33[0m"
sleep 10
cd ..
cd apache_$ApacheVersion
./configure --prefix=/usr/local/apache \
--enable-module=so --enable-module=rewrite \
--mandir=/usr/share/man &&
make &&
make install &&
/usr/local/apache/bin/apachectl start &&
#开始安装mysql软件包
echo -ne "\33[32m\33[5m\33[1m Configure And Install MySQL \33[0m"
sleep 10
cd ..
cd mysql-$MySQLVersion
./configure --prefix=/usr/local/mysql &&
make &&
make install &&
groupadd mysql &&
useradd -g mysql mysql &&
./scripts/mysql_install_db &&
chown -R mysql.mysql /usr/local/mysql/var &&
cp support-files/my-large.cnf /etc/my.cnf &&
cp /usr/local/mysql/lib/mysql/* /usr/lib/ &&
/usr/local/mysql/bin/mysqld_safe --user=mysql &
echo -ne "\33[32m\33[1m Please Set Your MySQL root Password: \33[0m"
read password
/usr/local/mysql/bin/mysqladmin -u root password $password
touch /usr/local/mysql/passwd.root
echo $password > /usr/local/mysql/passwd.root
/usr/local/mysql/bin/mysqladmin -u root --password=$password shutdown
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
# chkconfig --add mysqld
# /etc/rc.d/init.d/mysqld start
#开始安装php软件包
echo -ne "\33[32m\33[5m\33[1m Configure And Install PHP \33[0m"
sleep 10
cd ..
cd php-$PHPVersion
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs=/usr/local/apache/bin/apxs \
--with-gd=/usr/local/gd \
--with-zlib=/usr/local/zlib \
--with-jpeg-dir=/usr/local/jpeg \
--with-freetype-dir=/usr/local/freetype \
--mandir=/usr/share/man &&
make &&
make install &&
cp php.ini-dist /usr/local/php/lib/php.ini &&
sed -i 's/DirectoryIndex index.html/DirectoryIndex index.html index.php/g' /usr/local/apache/conf/httpd.conf
sed -i '/AddType application\/x-tar .tgz/a\ AddType application\/x-httpd-php .php' /usr/local/apache/conf/httpd.conf
sed -i '/AddType application\/x-tar .tgz/a\ AddType application\/x-httpd-source .phps' /usr/local/apache/conf/httpd.conf
sed -i 's/"register_globals = Off"/"register_globals = On"/g' /usr/local/php/lib/php.ini
/usr/local/apache/bin/apachectl restart
#开始安装pureftpd软件包
echo -ne "\33[32m\33[5m\33[1m Configure And Install pureftpd \33[0m"
sleep 10
cd ..
cd pure-ftpd-$PureftpdVersion
./configure --prefix=/usr/local/pureftpd --with-mysql=/usr/local/mysql \
--with-paranoidmsg \
--with-shadow \
--with-welcomemsg \
--with-uploadscript \
--with-quotas \
--with-cookie \
--with-pam \
--with-virtualhosts \
--with-virtualroot \
--with-diraliases \
--with-sysquotas \
--with-ratios \
--with-ftpwho \
--with-throttling &&
make &&
make install &&
cd configuration-file/
chmod u+x pure-config.pl &&
cp pure-config.pl /usr/local/sbin/ &&
cp pure-ftpd.conf /usr/local/etc/ &&
mkdir ftpweb &&
cd ../../ &&
mv pureftpd_php_manager.zip ftpweb/
cd ftpweb
unzip pureftpd_php_manager.zip &&
rm -f pureftpd_php_manager.zip
cd ..
cp -R $INSTALL/ftpweb /usr/local/apache/htdocs/ &&
rm -rf ftpweb/
mv /usr/local/apache/htdocs/ftpweb/pureftpd-mysql.conf.sample /usr/local/etc/pureftpd-mysql.conf &&
rm -f /usr/local/apache/htdocs/ftpweb/pureftp.config.php
mv $INSTALL/pureftp.config.php /usr/local/apache/htdocs/ftpweb/
/usr/local/mysql/bin/mysql -u root --password=$password <<EOF
create database pureftpd;
use pureftpd;
DROP TABLE IF EXISTS ftpd;
CREATE TABLE ftpd (
User varchar(16) NOT NULL default '',
status enum('0','1') NOT NULL default '0',
Password varchar(64) NOT NULL default '',
Uid varchar(11) NOT NULL default '-1',
Gid varchar(11) NOT NULL default '-1',
Dir varchar(128) NOT NULL default '',
ULBandwidth smallint(5) NOT NULL default '0',
DLBandwidth smallint(5) NOT NULL default '0',
comment tinytext NOT NULL,
ipaccess varchar(15) NOT NULL default '*',
QuotaSize smallint(5) NOT NULL default '0',
QuotaFiles int(11) NOT NULL default 0,
PRIMARY KEY (User),
UNIQUE KEY User (User)
) TYPE=MyISAM;
grant all on pureftpd.* to pureftpd@localhost identified by '123456';
EOF
rm -f /usr/local/etc/pureftpd-mysql.conf
mv $INSTALL/pureftpd-mysql.conf /usr/local/etc/
#启动FTP服务
/usr/local/sbin/pure-config.pl /usr/local/etc/pure-ftpd.conf
#然后测试http://ip/ftpweb/index.php
#添加一个用户,然后用FTP客户端登陆试试,ok!
#完成安装
echo "Congrutations!"
echo -ne "\33[32m\33[5m\33[1m Apache,MySQL and PHP are installed on your system! \33[0m" |
|