Install Asterisk on a Netbook

My Asterisk server was integrated with my VDR and runs on the main server in the lounge. This system works perfectly but I want more flexibility.
If I need to power off the server, I lose all my voip capabilities. So I want a small, silent, low power system that can provide me with Asterisk.
I currently have a Netbook EEEPC 701 which does have some limitations. I hate the keyboard, and as I get older I am finding the screen harder and harder to read. The netbook sits by my bedside so in the morning while watching the news, I can quickly catchup on my emails / websites. This works but I cannot reliably reply to emails and small print on a 7 inch screen is not easy to read. So it is time to upgrade and put this netbook to good use.
My solution was to install Asterisk on the netbook, and to achieve this I needed a more complete linux installation than the current Xandros.
I decided that I would like to use Ubuntu as this has now been built for the eeepc :)
To start off I chose easypeasy. This is a full iso of just less that 1 GB and it is downloaded and installed to a usb pendrive (minimum 2GB). The iso download took about 45 minutes and I used the Ubuntu windows installer to transfer the iso to the pendrive to create a bootable device. The installation to the pendrive was slow so that was why I decided to write this tutorial while I waited (about 30 minutes)
As I currently have a fully working Asterisk / Freepbx system, I should be able to use a 'full' Freepbx backup to simplify all configuration on the netbook.
One thing that concerned me was that Ubuntu is primarily a GUI version of Linux and I am only interested in running a server. I would like a FOP (Flash Operator Panel) display, and by running Firefox on the netbook I then have a full FOP capability.
So this little netbook will just sit and display what is happening, and should not need any keyboard interaction. Any configuration can be done via freepbx, and low level configs are done using SSH.
Once the pendrive had been created, it was then just a question of sorting out the bios to correctly boot from it.
The installer ran, and an easypeasy splash screen was shown. After about a minute, the screen changed and now shows the easypeasy main GUI :) This is the equivalent of a live CD, and by choosing Administration, you can then install it to your netbook disk (SSD). The installation entailed choosing your language, location, keyboard and disk partitioning and leave the software to copy everything from the pen drive onto your hard disk. The hard disk install takes about 20 minutes to complete. So while I was waiting (and probably you), why not have a look around the ubuntu interface. My first impressions are 'clean', I like the layout and colours and within about a minute I had the wireless interface connected to my network.
Once the installation to hard disk was complete, it was necessary to reboot. Again (as expected) I needed to connect to my wireless network.
The wireless network connection is NOT reliable and there is a patch to fix this problem, the easiest solution was to use my wired connection.
Because I dislike using the keyboard on the eeepc, my first priority was to get an ssh connection from another computer (my laptop). To install ssh, you need to open a terminal window and enter
sudo apt-get install openssh-server - this unfortunately gave an error, and I needed to go to the Administer menu and run the Update manager. Once I had installed updates, running
sudo apt-get install openssh-server
worked perfectly and I am now able to log in from my laptop using ssh.
To get Asterisk and Freepbx installed I followed the posting by pmoore4321 at the eeuser forum, which worked perfectly 
To install you can copy and paste the following - beware of comments (in red) and where there are lines, you will need to complete to that point then start the next block.
Don't set passwords for mysql (just hit enter) and enter 127.0.0.1 when
prompted for ip during freepbx install. I changed my web root from
/var/www/html to /var/www
From a terminal or ssh login use :
sudo su (enter your password)
I needed to create a user and group called asterisk
dpkg-reconfigure dash (choose No)
/etc/init.d/apparmor stop
update-rc.d -f apparmor remove
aptitude remove apparmor apparmor-utils (enter y)
apt-get -y install php5-mysql libapache2-mod-php5 mysql-server ntp (asked 3 times for password - enter rtn)
a2enmod php5
sed -i "s/magic_quotes_gpc = On/magic_quotes_gpc = Off/" /etc/php5/apache2/php.ini
sed -i "s/memory_limit = 16M/memory_limit = 100M/" /etc/php5/apache2/php.ini
sed -i "s/iso-8859-1/utf8/" /etc/php5/apache2/php.ini
sed -i "s/;default_charset/default_charset/" /etc/php5/apache2/php.ini
mkdir /var/run/asterisk
mkdir /var/log/asterisk
chown asterisk:asterisk /var/log/asterisk
apt-get -y install asterisk asterisk-mysql asterisk-mp3 php-db php5-gd php-pear sox curl asterisk-sounds-extra
adduser www-data asterisk
sed -i "s/export APACHE_RUN_USER=www-data/export APACHE_RUN_USER=asterisk/" /etc/apache2/envvars
sed -i "s/export APACHE_RUN_GROUP=www-data/export APACHE_RUN_GROUP=asterisk/" /etc/apache2/envvars
usermod -s /bin/bash asterisk
cd /usr/local/src
wget http://mirror.freepbx.org/freepbx-2.7.0.tar.gz (or latest version)
tar xvfz freepbx*
cd freepbx*
mysqladmin create asterisk
mysqladmin create asteriskcdrdb
mysql asterisk < SQL/newinstall.sql
mysql asteriskcdrdb < SQL/cdr_mysql_table.sql
mysql -vv -e "GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY 'amp109'"
mysql -vv -e "GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY 'amp109'"
mysql -vv -e "flush privileges"
cp /etc/asterisk/modules.conf /etc/asterisk/modules.conf.old
pear install DB
./install_amp (enter 5 rtns, followed by /var/www for web root, followed by IP address of netbook + 4 rtns)
rm -rf /etc/asterisk/modules.conf
mv /etc/asterisk/modules.conf.old /etc/asterisk/modules.conf
sed -i "s/BACKGROUND=0/BACKGROUND=1/" /usr/sbin/safe_asterisk
ln -s /var/lib/asterisk/sounds/custom /usr/local/share/asterisk/sounds/
chown asterisk:asterisk -R /usr/share/asterisk
chmod 755 -R /usr/share/asterisk
chown -R asterisk:asterisk /usr/local/share/asterisk/
update-rc.d -f asterisk remove
cat >/etc/rc.local << EOF
mkdir /var/log/apache2
mkdir /var/log/asterisk
chown asterisk:asterisk /var/log/asterisk
chmod 775 /var/run
/usr/sbin/apache2ctl graceful
/usr/local/sbin/amportal start
exit 0
EOF
chmod 755 /etc/rc.local
mv /usr/local/share/asterisk/sounds /usr/local/share/asterisk/sounds.old
ln -s /var/lib/asterisk/sounds/custom /usr/local/share/asterisk/sounds
cd /tmp
apt-get install -y linux-headers-2.6.27-8-eeepc
wget http://downloads.digium.com/pub/zaptel/zaptel-1.4-current.tar.gz
tar xfz zaptel-1.4-current.tar.gz
cd `find . -name "zaptel-1.4.*" -print`
./configure
make install config
wget http://kent.dl.sourceforge.net/sourceforge/webadmin/webmin_1.480_all.deb
apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl libmd5-perl
dpkg --install webmin_1.480_all.deb
apt-get install -y postfix mailutils
reboot
With a bit of luck your system should reboot and both asterisk and apache2 are running :)
While setting up Asterisk/Freepbx I noticed that the creation of recordings was working fine, but when the recording was used in an IVR there was just silence. After research I found that I needed to alter some folder locations (thanks to clarknova at freepbx) so built solution into script.
A further problem was that although I could create a conference, whenever I dialed the conference number I always got the message "That is not a valid conference number". Again with further reading this is normally due to zaptel driver not being installed. I thought that as I had no zaptel hardware, it was not necessary to install zaptel but it appears I was wrong :(
I always like my voicemail to be sent as an email, so I installed postfix.
prompted for ip during freepbx install. I changed my web root from
/var/www/html to /var/www
dpkg-reconfigure dash (choose No)
/etc/init.d/apparmor stop
update-rc.d -f apparmor remove
aptitude remove apparmor apparmor-utils (enter y)
apt-get -y install php5-mysql libapache2-mod-php5 mysql-server ntp (asked 3 times for password - enter rtn)
a2enmod php5
sed -i "s/magic_quotes_gpc = On/magic_quotes_gpc = Off/" /etc/php5/apache2/php.ini
sed -i "s/memory_limit = 16M/memory_limit = 100M/" /etc/php5/apache2/php.ini
sed -i "s/iso-8859-1/utf8/" /etc/php5/apache2/php.ini
sed -i "s/;default_charset/default_charset/" /etc/php5/apache2/php.ini
mkdir /var/run/asterisk
mkdir /var/log/astersik
chown asterisk:asterisk /var/log/asterisk
apt-get -y install asterisk asterisk-mysql asterisk-mp3 php-db php5-gd php-pear sox curl asterisk-sounds-extra
adduser www-data asterisk
sed -i "s/export APACHE_RUN_USER=www-data/export APACHE_RUN_USER=asterisk/" /etc/apache2/envvars
sed -i "s/export APACHE_RUN_GROUP=www-data/export APACHE_RUN_GROUP=asterisk/" /etc/apache2/envvars
usermod -s /bin/bash asterisk
cd /usr/local/src
wget http://mirror.freepbx.org/freepbx-2.5.1.tar.gz
tar xvfz freepbx-2.5.1.tar.gz
cd freepbx-2.5.1
mysqladmin create asterisk
mysqladmin create asteriskcdrdb
mysql asterisk < SQL/newinstall.sql
mysql asteriskcdrdb < SQL/cdr_mysql_table.sql
mysql -vv -e "GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY 'amp109'"
mysql -vv -e "GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY 'amp109'"
mysql -vv -e "flush privileges"
cp /etc/asterisk/modules.conf /etc/asterisk/modules.conf.old
./install_amp (enter 5 rtns, followed by /var/www for web root, followed by IP address of netbook + 4 rtns)
rm -rf /etc/asterisk/modules.conf
mv /etc/asterisk/modules.conf.old /etc/asterisk/modules.conf
sed -i "s/BACKGROUND=0/BACKGROUND=1/" /usr/sbin/safe_asterisk
ln -s /var/lib/asterisk/sounds/custom /usr/local/share/asterisk/sounds/
chown asterisk:asterisk -R /usr/share/asterisk
chmod 755 -R /usr/share/asterisk
chown -R asterisk:asterisk /usr/local/share/asterisk/
update-rc.d -f asterisk remove
cat >/etc/rc.local << EOF
mkdir /var/log/apache2
mkdir /var/log/asterisk
chown asterisk:asterisk /var/log/asterisk
chmod 775 /var/run
/usr/sbin/apache2ctl graceful
/usr/local/sbin/amportal start
exit 0
EOF
chmod 755 /etc/rc.local
mv /usr/local/share/asterisk/sounds /usr/local/share/asterisk/sounds.old
ln -s /var/lib/asterisk/sounds/custom /usr/local/share/asterisk/sounds
cd /tmp
apt-get install -y linux-headers-2.6.27-8-eeepc
wget http://downloads.digium.com/pub/zaptel/zaptel-1.4-current.tar.gz
tar xfz zaptel-1.4-current.tar.gz
cd `find . -name "zaptel-1.4.*" -print`
./configure
make install config
wget http://kent.dl.sourceforge.net/sourceforge/webadmin/webmin_1.480_all.deb
apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl libmd5-perl
dpkg --install webmin_1.480_all.deb
apt-get install -y postfix mailutils
reboot