Tuesday, March 11, 2008

Installing MySQL and PHP4 with apache1.3

Continued from previous post

#!/bin/bash
cd /usr/src

wget  http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.51a.tar.gz/from/http://mysql.mirror.rafal.ca/
tar xzvf mysql-5.0.51a.tar.gz
cd mysql-5.0.51a
groupadd mysql
useradd -g mysql mysql
./configure
make
make install
cp support-files/my-small.cnf /etc/my.cnf
cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .
bin/mysql_install_db --user=mysql
chown -R root .
chown -R mysql var
bin/mysqld_safe --user=mysql &

wget http://ca3.php.net/get/php-4.4.8.tar.gz/from/ca.php.net/mirror
tar zxvf php-4.4.8.tar.gz
cd php-4.4.8
#assumes apache was configure as DSO
./configure --with-apxs=/usr/local/apache/bin/apxs
make
make install
Review /usr/local/apache/conf/httpd.conf LoadModule php4_module libexec/libphp4.so should already be in the config file Add or verify Addtype application/x-httpd-php .php Addtype application/x-httpd-php-source .phps

Install Apache with modssl from source

copy and paste the following into a new file then chmod it to 755
#!/bin/bash

cd /usr/src
wget http://www.openssl.org/source/openssl-0.9.8g.tar.gz
tar xzvf openssl-0.9.8g.tar.gz
cd openssl-0.9.8g
./config
read -p "If ./config finished press enter to make"
make
read -p "If make finished press enter to make install"
make install
read -p "If make install finished press enter to install apache and modssl "

wget http://archive.apache.org/dist/httpd/apache_1.3.41.tar.gz
tar zxvf apache_1.3.41.tar.gz
wget http://www.modssl.org/source/mod_ssl-2.8.31-1.3.41.tar.gz
tar xzvf mod_ssl-2.8.31-1.3.41.tar.gz
cd mod_ssl-2.8.31-1.3.41
./configure --with-apache=../apache_1.3.41 \
 --with-ssl=../openssl-0.9.8g \
 --prefix=/usr/local/apache \
 --enable-shared=max
read -p "If ./configure finished press enter to make"
cd ../apache_1.3.41
make
read -p "If make finished press enter to make install"
make certificate
make install

Thursday, January 03, 2008

Asterisk Install Script for Debian

#!/bin/bash

# Script to download and untar lastest asterisk build
# Justin Hamade v1 - March 24, 2007
# Justin Hamade v1.1 - May 28, 2007 - Added:
# 1. ability to install 1.2 or 1.4
# 2. dep check for wget, make, and gcc
# 3. install asterisk-gui option for 1.4


# ----------------------------------------------------------------------------
# Pause.
# ----------------------------------------------------------------------------
pause()
{

        if test $NONINTERACTIVE; then
                return 0
        fi

        [ $# -ne 0 ] && echo -e $* >&2
        echo -e "Press [Enter] to continue...\c" >&2
        read tmp
        return 0
}
# ----------------------------------------------------------------------------
# Prompt user for input.
# Usage:
# prompt "Prompt"
# $CMD
# ----------------------------------------------------------------------------
prompt()
{
        if test $NONINTERACTIVE; then
                return 0
        fi

        echo -ne "$*" >&2
        read CMD rest
        return 0
}

# ----------------------------------------------------------------------------
# Get Yes/No
# Usage:
# getyn "\nWould you like to continue?" || return 1
# ----------------------------------------------------------------------------
getyn()
{
        if test $NONINTERACTIVE; then
                return 0
        fi

        while prompt "$* (y/n) "
        do      case $CMD in
                        [yY])   return 0
                                ;;
                        [nN])   return 1
                                ;;
                        *)      echo -e "\nPlease answer y or n" >&2
                                ;;
                esac
        done
}
# ----------------------------------------------------------------------------
# Get Version
# ----------------------------------------------------------------------------
getversion()
{
        if test $NONINTERACTIVE; then
                return 0
        fi

        while prompt "Enter $* minor version number (for 1.$BRANCH.0 enter 0 for 1.$BRANCH.1.1 enter 1.1): "
        do      case $CMD in
                        [0-9]|[1-2][0-9]|[0-9].[0-9]|[1-2][0-9].[0-9])
                                return 0
                                ;;
                        *)      echo -e "Please answer a number from 0 to 29" >&2
                                ;;
                esac
        done
}

getbranch()
{
        if test $NONINTERACTIVE; then
                return 0
        fi

        while prompt "Enter asterisk branch number (for 1.2 enter 2 for 1.4 enter 4): "
        do      case $CMD in
                        [2]|[4])
                                return 0
                                ;;
                        *)      echo -e "Please enter 2 or 4" >&2
                                ;;
                esac
        done
}

install_libpri ()
{
        getyn "Install libpri?" || return 1
        LIBPRIVERSION=0
        getversion "libpri"
        LIBPRIVERSION=$CMD
        cd $SRCDIR
        wget ftp://ftp.digium.com/pub/libpri/libpri-1.$BRANCH.$LIBPRIVERSION.tar.gz
        tar zxvf libpri-1.$BRANCH.$LIBPRIVERSION.tar.gz
        rm libpri-1.$BRANCH.$LIBPRIVERSION.tar.gz
        cd $SRCDIR/libpri-1.$BRANCH.$LIBPRIVERSION
        make && make install
        cd $SRCDIR
}

install_zaptel ()
{
        getyn "Install zaptel?" || return 1
        ZAPTELVERSION=1
        getversion "zaptel"
        ZAPTELVERSION=$CMD
        cd $SRCDIR
        wget ftp://ftp.digium.com/pub/zaptel/zaptel-1.$BRANCH.$ZAPTELVERSION.tar.gz
        tar zxvf zaptel-1.$BRANCH.$ZAPTELVERSION.tar.gz
        rm zaptel-1.$BRANCH.$ZAPTELVERSION.tar.gz
        ln -s $SRCDIR/zaptel-1.$BRANCH.$ZAPTELVERSION /usr/src/zaptel
        cd $SRCDIR/zaptel-1.$BRANCH.$ZAPTELVERSION
        if [ "$BRANCH" = "4" ]; then
                ./configure && make menuselect
        fi
        make && make install
        cd $SRCDIR
}

install_asterisk ()
{
        getyn "Install asterisk?" || return 1
        ASTERISKVERSION=2
        getversion "asterisk"
        ASTERISKVERSION=$CMD
        cd $SRCDIR
        wget ftp://ftp.digium.com/pub/asterisk/asterisk-1.$BRANCH.$ASTERISKVERSION.tar.gz
        tar zxvf asterisk-1.$BRANCH.$ASTERISKVERSION.tar.gz
        rm asterisk-1.$BRANCH.$ASTERISKVERSION.tar.gz
        cd $SRCDIR/asterisk-1.$BRANCH.$ASTERISKVERSION
        if [ "$BRANCH" = "4" ]; then
                ./configure && make menuselect
        fi
        make && make install
        cd $SRCDIR
}

install_addons ()
{
        getyn "Install asterisk-addons?" || return 1
        ADDONSVERSION=0
        getversion "addons"
        ADDONSVERSION=$CMD
        cd $SRCDIR
        wget ftp://ftp.digium.com/pub/asterisk/asterisk-addons-1.$BRANCH.$ADDONSVERSION.tar.gz
        tar zxvf asterisk-addons-1.$BRANCH.$ADDONSVERSION.tar.gz
        rm asterisk-addons-1.$BRANCH.$ADDONSVERSION.tar.gz
        cd $SRCDIR/asterisk-addons-1.$BRANCH.$ADDONSVERSION
        if [ "$BRANCH" = "4" ]; then
                ./configure && make menuselect
        fi
        make && make install
        cd $SRCDIR
}
install_gui ()
{
        getyn "Install asterisk-gui?" || return 1
        cd $SRCDIR
        svn checkout http://svn.digium.com/svn/asterisk-gui/trunk asterisk-gui
        cd $SRCDIR/asterisk-gui
        ./configure && make && make install && make samples
        cd $SRCDIR
}
install_sounds ()
{
        getyn "Install asterisk-sounds?" || return 1
        SOUNDSVERSION=0
        getversion "sounds"
        SOUNDSVERSION=$CMD
        cd $SRCDIR
        wget ftp://ftp.digium.com/pub/asterisk/asterisk-sounds-1.$BRANCH.$ADDONSVERSION.tar.gz
        tar zxvf asterisk-sounds-1.$BRANCH.$SOUNDSVERSION.tar.gz
        rm asterisk-sounds-1.$BRANCH.$SOUNDSVERSION.tar.gz
        cd $SRCDIR/asterisk-sounds-1.$BRANCH.$SOUNDSVERSION
        make install
        cd $SRCDIR
}
install_wanpipe ()
{
        getyn "Install sangoma wanpipe?" || return 1
        prompt "Enter wanpipe version (ie 2.3.4-9 or 3.1.0)"
        WANPIPEVERSION=$CMD
        cd $SRCDIR
        wget ftp://ftp.sangoma.com/linux/current_wanpipe/wanpipe-$WANPIPEVERSION.tgz
        tar zxvf wanpipe-$WANPIPEVERSION.tgz
        rm wanpipe-$WANPIPEVERSION.tgz
        cd $SRCDIR/wanpipe-$WANPIPEVERSION
        ./Setup install
        cd $SRCDIR
}

banner ()
{
        cat << ENDOFTEXT
This script will download and install Asterisk 1.2 or 1.4 and its required packages including Sangoma drivers.
ENDOFTEXT
pause
}

checkwget ()
{
        echo "Checking wget ...";
        if [ ! -x $WGET ]; then
                getyn "wget not installed run, apt-get install wget?" || return 1
                apt-get install wget
        fi
        echo "success"
}
checkmake ()
{
        echo "Checking make ...";
        if [ ! -x $MAKE ]; then
                getyn "make not installed, run apt-get install make?" || return 1
                apt-get install make
        fi
        echo "success"
}
checkgcc ()
{
        echo "Checking gcc ...";
        if [ ! -x $GCC ]; then
                getyn "gcc not installed, run apt-get install gcc?" || return 1
                apt-get install gcc
        fi
        echo "success"
}


banner
WGET=/usr/bin/wget
checkwget
MAKE=/usr/bin/make
checkmake
GCC=/usr/bin/gcc
checkgcc
getbranch
BRANCH=$CMD

SRCDIR="/usr/src/asterisk-1.$BRANCH"
if [ -d $SRCDIR ]; then
        echo "directory exsists"
else
        mkdir $SRCDIR
fi
cd $SRCDIR

install_libpri
install_zaptel
install_asterisk
install_addons
if [ "$BRANCH" = "2" ]; then
        install_sounds
fi
if [ "$BRANCH" = "4" ]; then
        install_gui
fi
install_wanpipe