#!/bin/sh
soft_path=/soft/tool
tar_path=/usr/local/src
apr_dir=/usr/local/src/apr-1.5.2
apr_util_dir=$tar_path/apr-util-1.5.4
httpd_dir=$tar_path/httpd-2.4.16
svn_dir=$tar_path/subversion-1.9.1
pcre_dir=$tar_path/pcre-8.36
sqlite_dir=$tar_path/sqlite-autoconf-3081101
scons_dir=$tar_path/scons-2.4.0
serf_dir=$tar_path/serf-1.3.8
soft_dir=/application
log=/tmp/install
IP=`ifconfig eth0 |awk -F "[ :]+" ‘NR==2 {print $4}‘`
RETVAL=0
function check () {
if [ $RETVAL -eq 0 ];then
echo "is ok"
else
echo "is error"
exit 1
fi
}
#################################### yum install ###################################
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~ yum install gcc ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
/etc/init.d/iptables stop
check
sed -i ‘s#SELINUX=enforcing#SELINUX=disabled#g‘ /etc/selinux/config
yum install gcc* openssl-devel zlib zlib-devel qlite httpd-tools -y
test -d /application && echo " /application directory exists" || mkdir /application -p
mkdir /tmp/install -p
mkdir /soft/tool -p
#################################### svn+httpd ####################################
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~ install svn+httpd ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
sleep 3
cd $soft_path
tar xf apr-1.5.2.tar.gz -C $tar_path
tar xf apr-util-1.5.4.tar.gz -C $tar_path
tar xf httpd-2.4.16.tar.gz -C $tar_path
tar xf subversion-1.9.1.tar.gz -C $tar_path
tar xf pcre-8.36.tar.gz -C $tar_path
tar xf scons-2.4.0.tar.gz -C $tar_path
tar jxf serf-1.3.8.tar.bz2 -C $tar_path
unzip sqlite-amalgamation-3071501.zip -d /usr/local/src/subversion-1.9.1
mv /usr/local/src/subversion-1.9.1/sqlite-amalgamation-3071501 /usr/local/src/subversion-1.9.1/sqlite-amalgamation
################################### install pcre ###################################
sleep 3
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~ pcre in install ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
cd $pcre_dir
./configure --prefix=$soft_dir/pcre && make && make install
################################### install apr ###################################
sleep 3
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~ apr install ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
cd $apr_dir
./configure --prefix=$soft_dir/apr && make && make install
################################### instal arp-util ################################
sleep 3
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~ arp-util install ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
cd $apr_util_dir
./configure --prefix=$soft_dir/apr-util --with-apr=$soft_dir/apr && make && make install
################################### install httpd ################################
sleep 3
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~ install in httpd ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
cd $httpd_dir
./configure --prefix=$soft_dir/apache2 --with-apr=$soft_dir/apr --with-apr-util=$soft_dir/apr-util \
--with-apr=$soft_dir/apr --with-pcre=$soft_dir/pcre --with-apr-util=$soft_dir/apr-util --enable-rewrite \
--enable-dav -enable-maintainer-mode --enable-dav-fs --enable-ssl --enable-so && make && make install
sed -i ‘s\#ServerName www.example.com:80\ServerName $IP\g‘ $soft_dir/apache2/conf/httpd.conf
$soft_dir/apache2/bin/apachectl -t
################################### instal scons ################################
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~ install in scons ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
cd $scons_dir
python setup.py install
sleep 3
################################### instal serf ################################
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~ install in serf ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
cd $serf_dir
scons PREFIX=$soft_dir/serf APR=$soft_dir/apr APU=$soft_dir/apr-util OPENSSL=/usr/bin
scons install
################################### install svn ################################
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~ install in svn ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
cd $svn_dir
./configure --prefix=$soft_dir/svn --with-apr=$soft_dir/apr --with-apr-util=$soft_dir/apr-util \
--with-apxs=$soft_dir/apache2/bin/apxs --with-serf=$soft_dir/serf && make && make install
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~ httpd config ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
cp -rp /application/svn/libexec/mod_authz_svn.so /application/apache2/modules/
cp -rp /application/svn/libexec/mod_dav_svn.so /application/apache2/modules/
echo -e "#set svnpath\n export PATH=/application/svn/bin:$PATH " >> /etc/profile
. /etc/profile
sed -i ‘/LoadModule dav_module modules/ a \LoadModule dav_svn_module modules/mod_dav_svn.so‘ /application/apache2/conf/httpd.conf
sed -i ‘/LoadModule dav_svn_module modules/ a \LoadModule authz_svn_module modules/mod_authz_svn.so‘ /application/apache2/conf/httpd.conf
sed -i ‘/httpd-vhosts.conf/ a #SVN ‘ /application/apache2/conf/httpd.conf
sed -i ‘/#SVN/ a Include conf/extra/httpd-svn.conf‘ /application/apache2/conf/httpd.conf
echo "<Location /svn>
DAV svn
SVNParentPath /svn/svndata
# our access control policy
AuthzSVNAccessFile /application/svn/conf/authz
# only authenticated users may access the repository
Require valid-user
# how to authenticate a user
AuthType Basic
AuthName Subversion repository
AuthUserFile /application/svn/conf/passwd
</Location>
" >/application/apache2/conf/extra/httpd-svn.conf
sed -i ‘s#Subversion repository#"Subversion repository"#g‘ /application/apache2/conf/extra/httpd-svn.conf
echo "################################### svn create ################################"
mkdir /svn/svndata -p
mkdir /application/svn/conf
svnadmin create /svn/svndata/sadoc
cp /svn/svndata/sadoc/conf/authz /application/svn/conf/
echo "please vim authen ## htpaswd /application/svn/conf/passwd"
useradd -s /sbin/nologin apache -M
chown -R apache.apache /svn/svndata
sed -i ‘s#User daemon#User apache#g‘ /application/apache2/conf/httpd.conf
sed -i ‘s#Group daemon#Group apache#g‘ /application/apache2/conf/httpd.conf
sed -i ‘/,&joe/ a admin = xing‘ /application/svn/conf/authz
htpasswd -cbm /application/svn/conf/passwd xing passwd
/application/apache2/bin/apachectl -k restart
echo "[sadoc:/]
@admin = rw
">>/application/svn/conf/authz
echo "please open http://$IP/svn/sadoc user=xing password=passwd"
svn co http://$IP/svn/sadoc --username=xing --password=passwd
本文出自 “小菜鸟” 博客,请务必保留此出处http://xiaocainiaox.blog.51cto.com/4484443/1697855
原文地址:http://xiaocainiaox.blog.51cto.com/4484443/1697855