1 Star 0 Fork 2

Z.X.PING/amh4.2

forked from 无情疯子/amh4.2 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
amh.sh 31.11 KB
一键复制 编辑 原始数据 按行查看 历史
无情疯子 提交于 2015-12-10 20:25 . no commit message
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
clear;
echo '================================================================';
echo ' [LNMP/Nginx] Amysql Host - AMH 4.2 (mod v44)';
echo ' http://Amysql.com';
echo '================================================================';
# VAR ***************************************************************************************
AMHDir='/home/amh_install/';
SysName='';
SysBit='';
Cpunum='';
RamTotal='';
RamSwap='';
InstallModel='';
Domain=`ifconfig | grep 'inet addr:'| egrep -v ":192.168|:172.1[6-9].|:172.2[0-9].|:172.3[0-2].|:10\.|:127." | cut -d: -f2 | awk '{ print $1}'`;
MysqlPass='';
AMHPass='';
StartDate='';
StartDateSecond='';
PHPDisable='';
# Version
AMSVersion='ams-1.5.0107-02';
AMHVersion='amh-4.2';
LibiconvVersion='libiconv-1.14';
PcreVersion='pcre-8.36';
ZlibVersion='zlib-1.2.8';
JemallocVersion='jemalloc-3.6.0';
MysqlVersion='mariadb-10.1.9';
PhpVersion='php-5.3.27p1';
Php54Version='php-5.4.45';
Php55Version='php-5.5.30';
Php56Version='php-5.6.16';
NginxVersion='nginx-1.8.0';
#OpenSSLVersion='openssl-1.0.2d';
OpenSSLVersion='openssl-1.0.2';
NginxCachePurgeVersion='ngx_cache_purge-2.3';
PureFTPdVersion='pure-ftpd-1.0.36';
GetUrl='git.oschina.net/zyuwl/amh4.2/raw/master';
NeusshblFiLe='/usr/local/bin/fetch_neusshbl.sh';
NeusshblLink='/etc/cron.hourly/fetch_neusshbl.sh';
# Function List *****************************************************************************
function CheckSystem()
{
[ $(id -u) != '0' ] && echo '[Error] Please use root to install AMH.' && exit;
egrep -i "centos" /etc/issue && SysName='centos';
egrep -i "debian" /etc/issue && SysName='debian';
egrep -i "ubuntu" /etc/issue && SysName='ubuntu';
[ "$SysName" == '' ] && echo '[Error] Your system is not supported install AMH' && exit;
SysBit='32' && [ `getconf WORD_BIT` == '32' ] && [ `getconf LONG_BIT` == '64' ] && SysBit='64';
Cpunum=`cat /proc/cpuinfo | grep 'processor' | wc -l`;
RamTotal=`free -m | grep 'Mem' | awk '{print $2}'`;
RamSwap=`free -m | grep 'Swap' | awk '{print $2}'`;
echo "Server ${Domain}";
echo "${SysBit}Bit, ${Cpunum}*CPU, ${RamTotal}MB*RAM, ${RamSwap}MB*Swap";
echo '================================================================';
RamSum=$[$RamTotal+$RamSwap];
[ "$SysBit" == '32' ] && [ "$RamSum" -lt '250' ] && \
echo -e "[Error] Not enough memory install AMH. \n(32bit system need memory: ${RamTotal}MB*RAM + ${RamSwap}MB*Swap > 250MB)" && exit;
if [ "$SysBit" == '64' ] && [ "$RamSum" -lt '480' ]; then
echo -e "[Error] Not enough memory install AMH. \n(64bit system need memory: ${RamTotal}MB*RAM + ${RamSwap}MB*Swap > 480MB)";
[ "$RamSum" -gt '250' ] && echo "[Notice] Please use 32bit system.";
exit;
fi;
[ "$RamSum" -lt '600' ] && PHPDisable='--disable-fileinfo';
}
function ConfirmInstall()
{
echo "[Notice] Confirm Install/Uninstall AMH? please select: (1~3)"
select selected in 'Install AMH 4.2' 'Uninstall AMH 4.2' 'Exit'; do break; done;
[ "$selected" == 'Exit' ] && echo 'Exit Install.' && exit;
if [ "$selected" == 'Install AMH 4.2' ]; then
InstallModel='1';
elif [ "$selected" == 'Uninstall AMH 4.2' ]; then
Uninstall;
else
ConfirmInstall;
return;
fi;
echo "[OK] You Selected: ${selected}";
read -p '[Notice] Do you want PHP5.4? : (y/n)' confirm54;
[ "$confirm54" == 'y' ] && echo '[OK] php5.4 will be installed';
read -p '[Notice] Do you want PHP5.5? : (y/n)' confirm55;
[ "$confirm55" == 'y' ] && echo '[OK] php5.5 will be installed';
read -p '[Notice] Do you want PHP5.6? : (y/n)' confirm56;
[ "$confirm56" == 'y' ] && echo '[OK] php5.6 will be installed';
}
function InputDomain()
{
if [ "$Domain" == '' ]; then
echo '[Error] empty server ip.';
read -p '[Notice] Please input server ip:' Domain;
[ "$Domain" == '' ] && InputDomain;
fi;
[ "$Domain" != '' ] && echo '[OK] Your server ip is:' && echo $Domain;
}
function InputMysqlPass()
{
read -p '[Notice] Please input MySQL password:' MysqlPass;
if [ "$MysqlPass" == '' ]; then
echo '[Error] MySQL password is empty.';
InputMysqlPass;
else
echo '[OK] Your MySQL password is:';
echo $MysqlPass;
fi;
}
function InputAMHPass()
{
read -p '[Notice] Please input AMH password:' AMHPass;
if [ "$AMHPass" == '' ]; then
echo '[Error] AMH password empty.';
InputAMHPass;
else
echo '[OK] Your AMH password is:';
echo $AMHPass;
fi;
}
function Timezone()
{
rm -rf /etc/localtime;
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime;
echo '[ntp Installing] ******************************** >>';
[ "$SysName" == 'centos' ] && yum install -y ntp || apt-get install -y ntpdate;
ntpdate -u pool.ntp.org;
StartDate=$(date);
StartDateSecond=$(date +%s);
echo "Start time: ${StartDate}";
}
function CloseSelinux()
{
[ -s /etc/selinux/config ] && sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config;
}
function DeletePackages()
{
if [ "$SysName" == 'centos' ]; then
yum -y remove httpd;
yum -y remove php;
yum -y remove mysql-server mysql;
yum -y remove php-mysql;
else
apt-get --purge remove nginx
apt-get --purge remove mysql-server;
apt-get --purge remove mysql-common;
apt-get --purge remove php;
fi;
}
function InstallBasePackages()
{
if [ "$SysName" == 'centos' ]; then
echo '[yum-fastestmirror Installing] ************************************************** >>';
yum -y install yum-fastestmirror;
cp /etc/yum.conf /etc/yum.conf.lnmp
sed -i 's:exclude=.*:exclude=:g' /etc/yum.conf
for packages in gcc gcc-c++ ncurses-devel libxml2 libxml2-devel openssl-devel curl-devel gd gd-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel autoconf kernel-devel pcre-devel libtool libtool-libs freetype freetype-devel zlib zlib-devel zip unzip wget crontabs iptables file bison cmake patch mlocate flex diffutils automake make readline-devel glibc-devel glibc-static glib2 glib2-devel bzip2 bzip2-devel gettext-devel libcap-devel logrotate ftp openssl expect; do
echo "[${packages} Installing] ************************************************** >>";
yum -y install $packages;
done;
mv -f /etc/yum.conf.lnmp /etc/yum.conf;
else
apt-get remove -y apache2 apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker mysql-client mysql-server mysql-common php;
killall apache2;
apt-get update;
for packages in build-essential gcc g++ cmake make ntp logrotate automake patch autoconf autoconf2.13 re2c wget flex cron libzip-dev libc6-dev rcconf bison cpp binutils unzip tar bzip2 libncurses5-dev libncurses5 libtool libevent-dev libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlibc openssl libsasl2-dev libxml2 libxml2-dev libltdl3-dev libltdl-dev zlib1g zlib1g-dev libbz2-1.0 libbz2-dev libglib2.0-0 libglib2.0-dev libpng3 libfreetype6 libfreetype6-dev libjpeg62 libjpeg62-dev libjpeg-dev libpng-dev libpng12-0 libpng12-dev curl libcurl3 libpq-dev libpq5 gettext libcurl4-gnutls-dev libcurl4-openssl-dev libcap-dev ftp openssl expect; do
echo "[${packages} Installing] ************************************************** >>";
apt-get install -y $packages --force-yes;apt-get -fy install;apt-get -y autoremove;
done;
fi;
}
function Downloadfile()
{
randstr=$(date +%s);
cd $AMHDir/packages;
if [ -s $1 ]; then
echo "[OK] $1 found.";
else
echo "[Notice] $1 not found, download now......";
if ! wget -c --tries=3 ${2}?${randstr} ; then
echo "[Error] Download Failed : $1, please check $2 ";
exit;
else
mv ${1}?${randstr} $1;
fi;
fi;
}
function InstallReady()
{
mkdir -p $AMHDir/conf;
mkdir -p $AMHDir/packages/untar;
chmod +Rw $AMHDir/packages;
mkdir -p /root/amh/;
chmod +Rw /root/amh;
cd $AMHDir/packages;
wget http://${GetUrl}/conf.zip;
unzip conf.zip -d $AMHDir/conf;
}
# Install Function *********************************************************
function Uninstall()
{
amh host list 2>/dev/null;
echo -e "\033[41m\033[37m[Warning] Please backup your data first. Uninstall will delete all the data!!! \033[0m ";
read -p '[Notice] Backup the data now? : (y/n)' confirmBD;
[ "$confirmBD" != 'y' -a "$confirmBD" != 'n' ] && exit;
[ "$confirmBD" == 'y' ] && amh backup;
echo '=============================================================';
read -p '[Notice] Confirm Uninstall(Delete All Data)? : (y/n)' confirmUN;
[ "$confirmUN" != 'y' ] && exit;
amh mysql stop 2>/dev/null;
amh php stop 2>/dev/null;
amh nginx stop 2>/dev/null;
killall nginx;
killall mysqld;
killall pure-ftpd;
killall php-cgi;
killall php-fpm;
[ "$SysName" == 'centos' ] && chkconfig amh-start off || update-rc.d -f amh-start remove;
rm -rf /etc/init.d/amh-start;
rm -rf /usr/local/libiconv;
rm -rf /usr/local/pcre;
rm -rf /usr/local/zlib;
rm -rf /usr/local/$OpenSSLVersion;
rm -rf /usr/local/openssl;
rm -rf /usr/local/ssl;
rm -rf /usr/local/jemalloc;
rm -rf /usr/local/nginx/;
rm -rf /usr/local/$PcreVersion;
rm -rf /usr/local/$ZlibVersion;
rm -rf /usr/local/$JemallocVersion;
for line in `ls /root/amh/modules`; do
amh module $line uninstall;
done;
rm -rf /etc/ld.so.conf.d/libiconv.conf /etc/ld.so.conf.d/pcre.conf /etc/ld.so.conf.d/zlib.conf /etc/ld.so.conf.d/jemalloc.conf;
rm -rf /usr/local/mysql/ /etc/my.cnf /etc/ld.so.conf.d/mysql.conf /usr/bin/mysql /var/lock/subsys/mysql /var/spool/mail/mysql;
rm -rf /usr/local/php/ /usr/local/php5.4/ /usr/local/php5.5/ /usr/local/php5.6/ /usr/lib/php /etc/php.ini /etc/php.d /usr/local/zend;
rm -rf /home/wwwroot/;
rm -rf /home/proxyroot/;
rm -rf /etc/pure-ftpd.conf /etc/pam.d/ftp /usr/local/sbin/pure-ftpd /etc/pureftpd.passwd /etc/amh-iptables;
rm -rf /etc/logrotate.d/nginx /root/.mysqlroot;
rm -rf /root/amh /bin/amh;
rm -rf $AMHDir;
rm -f /usr/bin/{mysqld_safe,myisamchk,mysqldump,mysqladmin,mysql,nginx,php-fpm,phpize,php};
echo '[OK] Successfully uninstall AMH.';
exit;
}
function InstallLibiconv()
{
echo "[${LibiconvVersion} Installing] ************************************************** >>";
Downloadfile "${LibiconvVersion}.tar.gz" "http://${GetUrl}/${LibiconvVersion}.tar.gz";
rm -rf $AMHDir/packages/untar/$LibiconvVersion;
echo "tar -zxf ${LibiconvVersion}.tar.gz ing...";
tar -zxf $AMHDir/packages/$LibiconvVersion.tar.gz -C $AMHDir/packages/untar;
if [ ! -d /usr/local/libiconv ]; then
cd $AMHDir/packages/untar/$LibiconvVersion;
./configure --prefix=/usr/local/libiconv;
make;
make install;
echo '/usr/local/libiconv/lib' > /etc/ld.so.conf.d/libiconv.conf;
echo "[OK] ${LibiconvVersion} install completed.";
else
echo '[OK] libiconv is installed!';
fi;
}
function InstallPcre()
{
echo "[${PcreVersion} Installing] ************************************************** >>";
if [ ! -d /usr/local/pcre ]; then
Downloadfile "${PcreVersion}.tar.gz" "http://${GetUrl}/${PcreVersion}.tar.gz";
rm -rf $AMHDir/packages/untar/$PcreVersion;
echo "tar -zxf ${PcreVersion}.tar.gz ...";
tar -zxf $AMHDir/packages/$PcreVersion.tar.gz -C /usr/local;
cd /usr/local/$PcreVersion;
./configure --prefix=/usr/local/pcre;
make;
make install;
echo '/usr/local/pcre/lib' > /etc/ld.so.conf.d/pcre.conf;
/sbin/ldconfig;
echo "[OK] ${PcreVersion} install completed.";
else
echo '[OK] pcre is installed!';
fi;
}
function InstallZlib()
{
echo "[${ZlibVersion} Installing] ************************************************** >>";
if [ ! -d /usr/local/zlib ]; then
Downloadfile "${ZlibVersion}.tar.gz" "http://${GetUrl}/${ZlibVersion}.tar.gz";
rm -rf $AMHDir/packages/untar/$ZlibVersion;
echo "tar -zxf ${ZlibVersion}.tar.gz ...";
tar -zxf $AMHDir/packages/$ZlibVersion.tar.gz -C /usr/local;
cd /usr/local/$ZlibVersion;
./configure --prefix=/usr/local/zlib;
make;
make install;
echo '/usr/local/zlib/lib' > /etc/ld.so.conf.d/zlib.conf;
/sbin/ldconfig;
echo "[OK] ${ZlibVersion} install completed.";
else
echo '[OK] zlib is installed!';
fi;
}
function InstallOpenSSL()
{
echo "[${OpenSSLVersion} Installing] ************************************************** >>";
Downloadfile "${OpenSSLVersion}.tar.gz" "http://${GetUrl}/${OpenSSLVersion}.tar.gz";
rm -rf $AMHDir/packages/untar/$OpenSSLVersion;
echo "tar -zxf ${OpenSSLVersion}.tar.gz ing...";
tar -zxf $AMHDir/packages/$OpenSSLVersion.tar.gz -C /usr/local;
if [ ! -d /usr/local/openssl ]; then
cd /usr/local/$OpenSSLVersion;
./config --prefix=/usr/local/openssl --openssldir=/usr/local/ssl;
make;
make install;
echo "[OK] ${OpenSSLVersion} tar completed.";
else
echo '[OK] openssl is installed!';
fi;
}
function InstallJemalloc()
{
echo "[${JemallocVersion} Installing] ************************************************** >>";
if [ ! -d /usr/local/jemalloc ]; then
Downloadfile "${JemallocVersion}.tar.gz" "http://${GetUrl}/${JemallocVersion}.tar.gz";
rm -rf $AMHDir/packages/untar/$JemallocVersion;
echo "tar -zxf ${JemallocVersion}.tar.gz ...";
tar -zxf $AMHDir/packages/$JemallocVersion.tar.gz -C /usr/local;
cd /usr/local/$JemallocVersion;
./configure --prefix=/usr/local/jemalloc;
make;
make install;
echo '/usr/local/jemalloc/lib' > /etc/ld.so.conf.d/jemalloc.conf;
/sbin/ldconfig;
echo "[OK] ${JemallocVersion} tar completed.";
else
echo '[OK] jemalloc is installed!';
fi;
}
function InstallSafeSshd()
{
echo "[SSH IP黑名单 安装中] ************************************************** >>";
if [ ! -a $NeusshblFiLe ] && [ ! -L $NeusshblLink ]; then
LIBWRAP=`ldd \`which sshd\` | grep libwrap | wc -l`;
if [ $LIBWRAP -ge 1 ]; then
cd /usr/local/bin/;
wget antivirus.neu.edu.cn/ssh/soft/fetch_neusshbl.sh;
chmod +x fetch_neusshbl.sh;
cd /etc/cron.hourly/;
ln -s /usr/local/bin/fetch_neusshbl.sh .;
./fetch_neusshbl.sh;
fi;
else
echo '[完成] SSH IP黑名单 已经安装.';
fi;
}
function InstallMysql()
{
# [dir] /usr/local/mysql/
echo "[${MysqlVersion} Installing] ************************************************** >>";
Downloadfile "${MysqlVersion}.tar.gz" "http://${GetUrl}/${MysqlVersion}.tar.gz";
rm -rf $AMHDir/packages/untar/$MysqlVersion;
echo "tar -zxf ${MysqlVersion}.tar.gz ing...";
tar -zxf $AMHDir/packages/$MysqlVersion.tar.gz -C $AMHDir/packages/untar;
if [ ! -f /usr/local/mysql/bin/mysql ]; then
cd $AMHDir/packages/untar/$MysqlVersion;
groupadd mysql;
useradd -s /sbin/nologin -g mysql mysql;
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=complex -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1;
#http://forge.mysql.com/wiki/Autotools_to_CMake_Transition_Guide
make -j $Cpunum;
make install;
chmod +w /usr/local/mysql;
chown -R mysql:mysql /usr/local/mysql;
rm -f /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf;
cp $AMHDir/conf/my.cnf /etc/my.cnf;
cp $AMHDir/conf/mysql /root/amh/mysql;
chmod +x /root/amh/mysql;
/usr/local/mysql/scripts/mysql_install_db --user=mysql --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data;
# EOF **********************************
cat > /etc/ld.so.conf.d/mysql.conf<<EOF
/usr/local/mysql/lib/mysql
/usr/local/lib
EOF
# **************************************
ldconfig;
if [ "$SysBit" == '64' ] ; then
ln -s /usr/local/mysql/lib/mysql /usr/lib64/mysql;
else
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql;
fi;
chmod 775 /usr/local/mysql/support-files/mysql.server;
/usr/local/mysql/support-files/mysql.server start;
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql;
ln -s /usr/local/mysql/bin/mysqladmin /usr/bin/mysqladmin;
ln -s /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump;
ln -s /usr/local/mysql/bin/myisamchk /usr/bin/myisamchk;
ln -s /usr/local/mysql/bin/mysqld_safe /usr/bin/mysqld_safe;
ln -s /usr/local/mysql/include/* /usr/local/include/
sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/jemalloc/lib/libjemalloc.so@' /usr/local/mysql/bin/mysqld_safe
/usr/local/mysql/bin/mysqladmin password $MysqlPass;
rm -rf /usr/local/mysql/data/test;
# EOF **********************************
mysql -hlocalhost -uroot -p$MysqlPass <<EOF
USE mysql;
DELETE FROM user WHERE User!='root' OR (User = 'root' AND Host != 'localhost');
UPDATE user set password=password('$MysqlPass') WHERE User='root';
DROP USER ''@'%';
FLUSH PRIVILEGES;
EOF
# **************************************
echo "[OK] ${MysqlVersion} install completed.";
else
echo '[OK] MySQL is installed.';
fi;
}
function InstallPhp()
{
# [dir] /usr/local/php
echo "[${PhpVersion} Installing] ************************************************** >>";
Downloadfile "${PhpVersion}.tar.gz" "${GetUrl}/${PhpVersion}.tar.gz";
rm -rf $AMHDir/packages/untar/$PhpVersion;
echo "tar -zxf ${PhpVersion}.tar.gz ing...";
tar -zxf $AMHDir/packages/$PhpVersion.tar.gz -C $AMHDir/packages/untar;
if [ ! -d /usr/local/php ]; then
cd $AMHDir/packages/untar/$PhpVersion;
groupadd www;
useradd -m -s /sbin/nologin -g www www;
if [ "$InstallModel" == '1' ]; then
./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-openssl=/usr/local/openssl --with-zlib=/usr/local/zlib --with-curl --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-mbstring --enable-zip --with-iconv=/usr/local/libiconv --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --without-pear $PHPDisable;
fi;
make -j $Cpunum;
make install;
cp $AMHDir/conf/php.ini /etc/php.ini;
cp $AMHDir/conf/php /root/amh/php;
cp $AMHDir/conf/phpver /root/amh/phpver;
mkdir -p /root/amh/fpm/sites;
mkdir -p /root/amh/sitesconf;
cp $AMHDir/conf/php-fpm.conf /usr/local/php/etc/php-fpm.conf;
cp $AMHDir/conf/php-fpm-template.conf /root/amh/fpm/php-fpm-template.conf;
chmod +x /root/amh/php;
chmod +x /root/amh/phpver;
mkdir /etc/php.d;
mkdir /usr/local/php/etc/fpm;
mkdir /usr/local/php/var/run/pid;
#mkdir -p /var/run/pid;
touch /usr/local/php/etc/fpm/amh.conf;
/usr/local/php/sbin/php-fpm;
ln -s /usr/local/php/bin/php /usr/bin/php;
ln -s /usr/local/php/bin/phpize /usr/bin/phpize;
ln -s /usr/local/php/sbin/php-fpm /usr/bin/php-fpm;
echo "[OK] ${PhpVersion} install completed.";
else
echo '[OK] PHP is installed.';
fi;
}
function InstallPhp54()
{
# [dir] /usr/local/php5.4
echo "[${Php54Version} Installing] ************************************************** >>";
Downloadfile "${Php54Version}.tar.gz" "http://${GetUrl}/${Php54Version}.tar.gz";
rm -rf $AMHDir/packages/untar/$Php54Version;
echo "tar -zxf ${Php54Version}.tar.gz ing...";
tar -zxf $AMHDir/packages/$Php54Version.tar.gz -C $AMHDir/packages/untar;
if [ ! -d /usr/local/php5.4 ]; then
cd $AMHDir/packages/untar/$Php54Version;
if [ "$InstallModel" == '1' ]; then
./configure --prefix=/usr/local/php5.4 --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-config-file-path=/usr/local/php5.4/etc --with-config-file-scan-dir=/etc/php.d/5.4 --with-openssl=/usr/local/openssl --with-zlib=/usr/local/zlib --with-curl --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-mbstring --enable-zip --with-iconv=/usr/local/libiconv --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --without-pear $PHPDisable;
fi;
make -j $Cpunum;
make install;
cp $AMHDir/conf/php54.ini /usr/local/php5.4/etc/php.ini;
mkdir -p /etc/php.d/5.4;
echo "[OK] ${Php54Version} install completed.";
else
echo '[OK] PHP5.4 is installed.';
fi;
}
function InstallPhp55()
{
# [dir] /usr/local/php5.5
echo "[${Php55Version} Installing] ************************************************** >>";
Downloadfile "${Php55Version}.tar.gz" "http://${GetUrl}/${Php55Version}.tar.gz";
rm -rf $AMHDir/packages/untar/$Php55Version;
echo "tar -zxf ${Php55Version}.tar.gz ing...";
tar -zxf $AMHDir/packages/$Php55Version.tar.gz -C $AMHDir/packages/untar;
if [ ! -d /usr/local/php5.5 ]; then
cd $AMHDir/packages/untar/$Php55Version;
if [ "$InstallModel" == '1' ]; then
./configure --prefix=/usr/local/php5.5 --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-config-file-path=/usr/local/php5.5/etc --with-config-file-scan-dir=/etc/php.d/5.5 --with-openssl=/usr/local/openssl --with-zlib=/usr/local/zlib --with-curl --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-mbstring --enable-zip --with-iconv=/usr/local/libiconv --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --enable-opcache --without-pear $PHPDisable;
fi;
make -j $Cpunum;
make install;
cp $AMHDir/conf/php55.ini /usr/local/php5.5/etc/php.ini;
mkdir -p /etc/php.d/5.5;
echo "[OK] ${Php55Version} install completed.";
else
echo '[OK] PHP5.5 is installed.';
fi;
}
function InstallPhp56()
{
# [dir] /usr/local/php5.6
echo "[${Php56Version} Installing] ************************************************** >>";
Downloadfile "${Php56Version}.tar.gz" "http://${GetUrl}/${Php56Version}.tar.gz";
rm -rf $AMHDir/packages/untar/$Php56Version;
echo "tar -zxf ${Php56Version}.tar.gz ing...";
tar -zxf $AMHDir/packages/$Php56Version.tar.gz -C $AMHDir/packages/untar;
if [ ! -d /usr/local/php5.6 ]; then
cd $AMHDir/packages/untar/$Php56Version;
if [ "$InstallModel" == '1' ]; then
./configure --prefix=/usr/local/php5.6 --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-config-file-path=/usr/local/php5.6/etc --with-config-file-scan-dir=/etc/php.d/5.6 --with-openssl=/usr/local/openssl --with-zlib=/usr/local/zlib --with-curl --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-mbstring --enable-zip --with-iconv=/usr/local/libiconv --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --enable-opcache --without-pear $PHPDisable;
fi;
make -j $Cpunum;
make install;
cp $AMHDir/conf/php56.ini /usr/local/php5.6/etc/php.ini;
mkdir -p /etc/php.d/5.6;
echo "[OK] ${Php56Version} install completed.";
else
echo '[OK] PHP5.6 is installed.';
fi;
}
function InstallNginx()
{
# [dir] /usr/local/nginx
echo "[${NginxVersion} Installing] ************************************************** >>";
Downloadfile "${NginxVersion}.tar.gz" "http://${GetUrl}/${NginxVersion}.tar.gz";
# Downloadfile "${NginxCachePurgeVersion}.tar.gz" "http://git.oschina.net/zyuwl/amh4.2/raw/master/${NginxCachePurgeVersion}.tar.gz";
rm -rf $AMHDir/packages/untar/$NginxVersion;
echo "tar -zxf ${NginxVersion}.tar.gz ing...";
tar -zxf $AMHDir/packages/$NginxVersion.tar.gz -C $AMHDir/packages/untar;
#echo "tar -zxf ${NginxCachePurgeVersion}.tar.gz ing...";
#tar -zxf $AMHDir/packages/$NginxCachePurgeVersion.tar.gz -C $AMHDir/packages/untar;
if [ ! -d /usr/local/nginx ]; then
cd $AMHDir/packages/untar/$NginxVersion;
./configure --prefix=/usr/local/nginx --user=www --group=www --with-openssl=/usr/local/$OpenSSLVersion --with-zlib=/usr/local/$ZlibVersion --with-pcre=/usr/local/$PcreVersion --with-jemalloc=/usr/local/$JemallocVersion --with-ipv6 --with-http_spdy_module --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_image_filter_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_auth_request_module --with-http_concat_module=shared --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_sysguard_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --without-http_uwsgi_module --without-http_scgi_module;
#cd /usr/local/$OpenSSLVersion;
#./config;
#cd $AMHDir/packages/untar/$NginxVersion;
make -j $Cpunum;
make install;
make dso_install;
mkdir -p /home/proxyroot/proxy_temp_dir;
mkdir -p /home/proxyroot/proxy_cache_dir;
chown www.www -R /home/proxyroot/proxy_temp_dir /home/proxyroot/proxy_cache_dir;
chmod -R 644 /home/proxyroot/proxy_temp_dir /home/proxyroot/proxy_cache_dir;
mkdir -p /home/wwwroot/index /home/backup /usr/local/nginx/conf/vhost/ /usr/local/nginx/conf/vhost_stop/ /usr/local/nginx/conf/rewrite/;
chown +w /home/wwwroot/index;
touch /usr/local/nginx/conf/rewrite/amh.conf;
cp $AMHDir/conf/proxy.conf /usr/local/nginx/conf/proxy.conf;
cp $AMHDir/conf/nginx.conf /usr/local/nginx/conf/nginx.conf;
cp $AMHDir/conf/nginx-host.conf /usr/local/nginx/conf/nginx-host.conf;
cp $AMHDir/conf/fcgi.conf /usr/local/nginx/conf/fcgi.conf;
cp $AMHDir/conf/fcgi-host.conf /usr/local/nginx/conf/fcgi-host.conf;
cp $AMHDir/conf/nginx /root/amh/nginx;
cp $AMHDir/conf/host /root/amh/host;
chmod +x /root/amh/nginx;
chmod +x /root/amh/host;
sed -i 's/www.amysql.com/'$Domain'/g' /usr/local/nginx/conf/nginx.conf;
cd /home/wwwroot/index;
mkdir -p tmp etc/rsa bin usr/sbin log;
touch etc/upgrade.conf;
chown mysql:mysql etc/rsa;
chmod 777 tmp;
[ "$SysBit" == '64' ] && mkdir lib64 || mkdir lib;
/usr/local/nginx/sbin/nginx;
/usr/local/php/sbin/php-fpm;
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx;
echo "[OK] ${NginxVersion} install completed.";
else
echo '[OK] Nginx is installed.';
fi;
}
function InstallPureFTPd()
{
# [dir] /etc/ /usr/local/bin /usr/local/sbin
echo "[${PureFTPdVersion} Installing] ************************************************** >>";
Downloadfile "${PureFTPdVersion}.tar.gz" "http://${GetUrl}/${PureFTPdVersion}.tar.gz";
rm -rf $AMHDir/packages/untar/$PureFTPdVersion;
echo "tar -zxf ${PureFTPdVersion}.tar.gz ing...";
tar -zxf $AMHDir/packages/$PureFTPdVersion.tar.gz -C $AMHDir/packages/untar;
if [ ! -f /etc/pure-ftpd.conf ]; then
cd $AMHDir/packages/untar/$PureFTPdVersion;
./configure --with-puredb --with-quotas --with-throttling --with-ratios --with-peruserlimits;
make -j $Cpunum;
make install;
cp contrib/redhat.init /usr/local/sbin/redhat.init;
chmod 755 /usr/local/sbin/redhat.init;
cp $AMHDir/conf/pure-ftpd.conf /etc;
cp configuration-file/pure-config.pl /usr/local/sbin/pure-config.pl;
chmod 744 /etc/pure-ftpd.conf;
chmod 755 /usr/local/sbin/pure-config.pl;
/usr/local/sbin/redhat.init start;
groupadd ftpgroup;
useradd -d /home/wwwroot/ -s /sbin/nologin -g ftpgroup ftpuser;
cp $AMHDir/conf/ftp /root/amh/ftp;
chmod +x /root/amh/ftp;
/sbin/iptables-save > /etc/amh-iptables;
sed -i '/--dport 21 -j ACCEPT/d' /etc/amh-iptables;
sed -i '/--dport 80 -j ACCEPT/d' /etc/amh-iptables;
sed -i '/--dport 8888 -j ACCEPT/d' /etc/amh-iptables;
sed -i '/--dport 10100:10110 -j ACCEPT/d' /etc/amh-iptables;
/sbin/iptables-restore < /etc/amh-iptables;
/sbin/iptables -I INPUT -p tcp --dport 21 -j ACCEPT;
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT;
/sbin/iptables -I INPUT -p tcp --dport 8888 -j ACCEPT;
/sbin/iptables -I INPUT -p tcp --dport 10100:10110 -j ACCEPT;
/sbin/iptables-save > /etc/amh-iptables;
echo 'IPTABLES_MODULES="ip_conntrack_ftp"' >>/etc/sysconfig/iptables-config;
touch /etc/pureftpd.passwd;
chmod 774 /etc/pureftpd.passwd;
echo "[OK] ${PureFTPdVersion} install completed.";
else
echo '[OK] PureFTPd is installed.';
fi;
}
function InstallAMH()
{
# [dir] /home/wwwroot/index/web
echo "[${AMHVersion} Installing] ************************************************** >>";
Downloadfile "${AMHVersion}.tar.gz" "http://${GetUrl}/${AMHVersion}.tar.gz";
rm -rf $AMHDir/packages/untar/$AMHVersion;
echo "tar -xf ${AMHVersion}.tar.gz ing...";
tar -xf $AMHDir/packages/$AMHVersion.tar.gz -C $AMHDir/packages/untar;
if [ ! -d /home/wwwroot/index/web ]; then
cp -r $AMHDir/packages/untar/$AMHVersion /home/wwwroot/index/web;
gcc -o /bin/amh -Wall $AMHDir/conf/amh.c;
chmod 4775 /bin/amh;
cp -a $AMHDir/conf/amh-backup.conf /home/wwwroot/index/etc;
cp -a $AMHDir/conf/html /home/wwwroot/index/etc;
cp $AMHDir/conf/{all,backup,revert,BRssh,BRftp,info,SetParam,module,crontab,upgrade} /root/amh;
cp -a $AMHDir/conf/modules /root/amh;
chmod +x /root/amh/all /root/amh/backup /root/amh/revert /root/amh/BRssh /root/amh/BRftp /root/amh/info /root/amh/SetParam /root/amh/module /root/amh/crontab /root/amh/upgrade;
SedMysqlPass=${MysqlPass//&/\\\&};
SedMysqlPass=${SedMysqlPass//\'/\\\\\'};
sed -i "s/'MysqlPass'/'${SedMysqlPass}'/g" /home/wwwroot/index/web/Amysql/Config.php;
chown www:www /home/wwwroot/index/web/Amysql/Config.php;
SedAMHPass=${AMHPass//&/\\\&};
SedAMHPass=${SedAMHPass//\'/\\\\\\\\\'\'};
sed -i "s/'AMHPass_amysql-amh'/'${SedAMHPass}_amysql-amh'/g" $AMHDir/conf/amh.sql;
/usr/local/mysql/bin/mysql -u root -p$MysqlPass < $AMHDir/conf/amh.sql;
echo "[OK] ${AMHVersion} install completed.";
else
echo '[OK] AMH is installed.';
fi;
}
function InstallAMS()
{
# [dir] /home/wwwroot/index/web/ams
echo "[${AMSVersion} Installing] ************************************************** >>";
Downloadfile "${AMSVersion}.tar.gz" "http://${GetUrl}/${AMSVersion}.tar.gz";
rm -rf $AMHDir/packages/untar/$AMSVersion;
echo "tar -xf ${AMSVersion}.tar.gz ing...";
tar -xf $AMHDir/packages/$AMSVersion.tar.gz -C $AMHDir/packages/untar;
if [ ! -d /home/wwwroot/index/web/ams ]; then
cp -r $AMHDir/packages/untar/$AMSVersion /home/wwwroot/index/web/ams;
chown www:www -R /home/wwwroot/index/web/ams/View/DataFile;
echo "[OK] ${AMSVersion} install completed.";
else
echo '[OK] AMS is installed.';
fi;
}
# AMH Installing ****************************************************************************
CheckSystem;
ConfirmInstall;
InputDomain;
InputMysqlPass;
InputAMHPass;
Timezone;
CloseSelinux;
DeletePackages;
InstallBasePackages;
InstallReady;
InstallLibiconv;
InstallPcre;
InstallZlib;
InstallOpenSSL;
InstallJemalloc;
InstallSafeSshd;
InstallMysql;
InstallPhp;
[ "$confirm54" == 'y' ] && InstallPhp54;
[ "$confirm55" == 'y' ] && InstallPhp55;
[ "$confirm56" == 'y' ] && InstallPhp56;
InstallNginx;
InstallPureFTPd;
InstallAMH;
InstallAMS;
if [ -s /usr/local/nginx ] && [ -s /usr/local/php ] && [ -s /usr/local/mysql ]; then
cp $AMHDir/conf/amh-start /etc/init.d/amh-start;
chmod 775 /etc/init.d/amh-start;
if [ "$SysName" == 'centos' ]; then
chkconfig --add amh-start;
chkconfig amh-start on;
else
update-rc.d -f amh-start defaults;
fi;
/etc/init.d/amh-start;
rm -rf $AMHDir;
echo '================================================================';
echo '[AMH] Congratulations, AMH 4.2 install completed.';
echo "AMH Management: http://${Domain}:8888";
echo 'User:admin';
echo "Password:${AMHPass}";
echo "MySQL Password:${MysqlPass}";
echo '';
echo '******* SSH Management *******';
echo 'Host: amh host';
echo 'PHP: amh php';
echo 'Nginx: amh nginx';
echo 'MySQL: amh mysql';
echo 'FTP: amh ftp';
echo 'Backup: amh backup';
echo 'Revert: amh revert';
echo 'SetParam: amh SetParam';
echo 'Module : amh module';
echo 'Crontab : amh crontab';
echo 'Upgrade : amh upgrade';
echo 'Info: amh info';
echo '';
echo '******* SSH Dirs *******';
echo 'WebSite: /home/wwwroot';
echo 'Nginx: /usr/local/nginx';
echo 'PHP: /usr/local/php';
echo 'MySQL: /usr/local/mysql';
echo 'MySQL-Data: /usr/local/mysql/data';
echo '';
echo "Start time: ${StartDate}";
echo "Completion time: $(date) (Use: $[($(date +%s)-StartDateSecond)/60] minute)";
echo 'More help please visit:http://amysql.com';
echo '================================================================';
else
echo 'Sorry, Failed to install AMH';
echo 'Please contact us: http://amysql.com';
fi;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Xiphin/amh4.2.git
git@gitee.com:Xiphin/amh4.2.git
Xiphin
amh4.2
amh4.2
master

搜索帮助