Repost from here
Asterisk Installation
There is a lot of very good howto’s explaining Asterisk installation. Take a look at this brief summary (Debian), but you can take a look at 1, 2 or 3 (in spanish).
Prerequisites
Be careful with iptables and selinux. If needed, edit /etc/selinux/config
and write:
SELINUX=disabled SELINUXTYPE=targeted
Then, disable iptables
iptables -F iptables-save > /etc/iptables.up.rules
or configure it to allow SIP (port 5060) and RTP (port 10000-20000) if you plan to use these protocols.
Now upgrade your system
apt-get update apt-get upgrade
And install packages needed for compilation of asterisk
apt-get install linux-headers-`uname -r` gcc g++ make libnewt-dev libncurses5-dev openssl libssl-dev zlib1g-dev
Asterisk Installation
Download source files and untar. Asterisk 1.6 is explained, but 1.8 looks similar.
wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.6.2.13.tar.gz tar zxvf asterisk-1.6.2.13.tar.gz
If you will use FreePBX, then install asterisk-addons
wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-addons-1.6.2.2.tar.gz tar zxvf asterisk-addons-1.6.2.2.tar.gz
Now compile
cd asterisk-1.6.2.13 make clean && ./configure --disable-xmldocs && make && make install && make config
If needed
make samples