Installing asterisk on Ubuntu is very easy, its a sequence of some simple commands.
Stock Ubuntu doesn't ship some with the packages that are required to compile Asterisk. First let's install those packages.
#apt-get install build-essential
#apt-get install linux-headers-`uname -r`
#apt-get install libssl-dev
#apt-get install ncurses-dev
#apt-get install libnewt-dev
#apt-get install zlib1g-dev
#apt-get install bison
Once you have these packages installed. Get libpri,Zaptel and asterisk release files from digium. After downloading the files follow the below mentioned order to install Asterisk
Go to the directory (/usr/src/ is common place for this) where you have libpri,zaptel and asterisk tar files downloaded and untar them using tar -zxvf filename.tar.gz . (Replace filename.tar.gz with appropriate name)
#cd /usr/src/libpri
#make
#make install
#cd /usr/src/zaptel
#./configure
#make
#make install
#make config
#cd /usr/src/asterisk
#./configure
#make
before doing 'make install' for Asterisk you can do 'make menuselect' for selecting any additional sound files or features that you want in asterisk.
Now run,
#make install
#make samples
To make asterisk run on system startup type the following commands.
#cp /usr/src/asterisk/contrib/init.d/rc.debian.asterisk /etc/init.d/asterisk
#update-rc.d asterisk defaults
Now you are ready to go, you can run asterisk by type the following command
#/etc/init.d/asterisk start