loading
I am currently looking for someone to help out with this blog. I didn't realize the scope that this blog would effect. Hits from countries in political strife and the like, people looking for a way to communicate outside of government control. If you would like to help please send me an email George dot Endrulat at Gmail dot Com.

Thursday, April 14, 2011

Install Asterisk on Ubuntu 10.04

Install Asterisk on Ubuntu 10.04

Install Asterisk on Ubuntu 10.04
Written by Randy Reed
Saturday, 28 August 2010 00:00
[UPDATE]
So i compiled the script all together now so check it out Here

I needed to test some PBX configurations but as I don't have a PBX at hand to use I thought that it
would be interesting to test, at last, Asterisk. At the same time, it would be nice to test Ubuntu 10.04
just one month and a half before its release.
For the test I've created an instance of vmware-server 2.0 where I've installed a basic
Ubuntu 10.04 Lucid alpha3 with up to date updates and static IP.
For the installation of Asterisk and its GUI FreePBX I've followed the script pointed out at Ubuntu's wiki
which works in Ubuntu 9.10; Hence all credits should go to the script authors.
That said and after a quick look to the script I've decided to not execute it blindly. I've seen some oddities
in it. For example, there is a "chown asterisk:asterisk /var/run"!. So I've preferred to make this step by
step howto using the script as a basis.
Basically, the steps in this howto are the same in that script. However there are many changes in the
syntax (because I prefer my own syntax). I've avoided some steps which I disliked. But I've resigned
myself to commit other steps which maybe should be reorganized or even be rewritten. Maybe If I
had more time for it I would have rewrote the script, but the job is just test a few things on a PBX and
after all everything works which is what really matters.


We start with a basic and up to date instance of Lucid Alpha 3 on vmware server.
Steps:
Install mysql (You should enter the password for the mysql root user; for example 1234):
aptitude update
aptitude install -y mysql-server
Install all other dependencies we will need later:
aptitude install -y build-essential linux-headers-`uname -r` openssh-server bison flex apache2
php5 php5-curl php5-cli php5-mysql php-pear php-db php5-gd curl sox libncurses5-dev libssl-dev
libmysqlclient15-dev mpg123 libxml2-dev
Download all the asterisk source packages that we are going to compile:
cd /usr/src/
xargs wget << SOURCES http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/releases/dahdi-linux-complete -2.2.1+2.2.1.tar.gz http://downloads.asterisk.org/pub/telephony/libpri/releases/libpri-1.4.10.2.tar.gz http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.6.2.6.tar.gz http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-addons-1.6.2.0.tar.gz SOURCES Once we have all the sources we will compile them. Reading the relevant configuration, at least read the README file, it is always a good idea. Compile and install dahdi; problably unnecessary for our vmware instance, but it wont hurt: tar xvf dahdi-linux-complete-2.2.1+2.2.1.tar.gz cd dahdi-linux-complete-2.2.1+2.2.1 make all && make install && make config libpri compilation and install: cd .. tar xvf libpri-1.4.10.2.tar.gz cd libpri-1.4.10.2 make && make install Now do the same with asterisk: cd .. tar xvf asterisk-1.6.2.6.tar.gz cd asterisk-1.6.2.6 ./configure make && make install Without forgetting to install the sample configurations: make samples Untar, compile and install the addons for asterisk: cd .. tar xvf asterisk-addons-1.6.2.0.tar.gz cd asterisk-addons-1.6.2.0 ./configure make && make install As before lets install the sample files: make samples Finally install the extra sounds for our new PBX: cd /var/lib/astersik/sounds wget -O - http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en- gsm-current.tar.gz | tar xvfz - Now we start doing some adjustments to make our installation work. We create the user "asterisk" and add the apache user to the "asterisk" group (not sure if this is needed): adduser asterisk --disabled-password --no-create-home --gecos "asterisk PBX user" adduser www-data asterisk Change the default user and group for apache to asterisk in apache2.conf (this is also a step that doesn't convince me much, but as it is just a test, lest follow the directives of the original script): cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf In the original script it is also proposed to modify the sha-bang of the /usr/sbin/safe_asterisk script from sh to bash: nano /usr/sbin/safe_asterisk change the first line from #!/bin/sh to #!/bin/bash Now create the script that will manage the asterisk service. Here I haven't made any changes on the original script, I've just added the basic information (init info) that should carry every init script: cat > /etc/init.d/asterisk <&2 exit 3 ;; esac exit 0 END_STARTUP make appropriate modifications to the asterisk init script to make it available at booting: chmod 755 /etc/init.d/asterisk update-rc.d asterisk defaults 90 10 We are almost done. Now we are going to install FreePBX, the graphical interface that we will install to manage Asterisk (now here comes the chaos; IMHO the following steps reorganized would be better): cd /usr/src/ wget -O - http://mirror.freepbx.org/freepbx-2.7.0.tar.gz | tar xvfz - cd freepbx-2.7.0/ Copy amportal.conf configuration file to /etc/: cp amportal.conf /etc/ Create the databases. Remember that we had used "1234" as the password for our mysql root user. Also we define a password for the asterisk database, eg 4321: export MYSQL_ROOT_PW=1234 export ASTERISK_DB_PW=4321 mysqladmin -u root -p${MYSQL_ROOT_PW} create asterisk mysqladmin -u root -p${MYSQL_ROOT_PW} create asteriskcdrdb mysql -u root -p${MYSQL_ROOT_PW} asterisk < SQL/newinstall.sql mysql -u root -p${MYSQL_ROOT_PW} asteriskcdrdb < SQL/cdr_mysql_table.sql mysql -u root -p${MYSQL_ROOT_PW} <<-END_PRIVS GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY "${ASTERISK_DB_PW}"; GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY "${ASTERISK_DB_PW}"; flush privileges; END_PRIVS And slightly modify the settings in /etc/amportal.conf (in the original script this is done before installing freepbx, so we do it too): sed -i "s/# \(AMPDBUSER=.*\)/\1/" /etc/amportal.conf sed -i "s/# \(AMPDBPASS=\).*/\1${ASTERISK_DB_PW}/" /etc/amportal.conf sed -i "s@\(AMPWEBROOT=\).*@\1/var/www/@" /etc/amportal.conf sed -i "s@\(FOPWEBROOT=\).*@\1/var/www/panel@" /etc/amportal.conf sed -i "s@\(FOPWEBADDRESS=\).*@PUTIPADDRESS@" /etc/amportal.conf Adjust some PHP.ini settings related to the use of memory (in the original script there are some changes that are not necessary for lucid): sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php5/apache2/php.ini Change the permissions of a series of directories: chown asterisk. /var/run/asterisk chown -R asterisk. /etc/asterisk chown -R asterisk. /var/{lib,log,spool}/asterisk chown -R asterisk. /var/www/ We enable the asterisk configuration as it is indicated in /etc/asterisk/asterisk.conf by removing the trailing characters in the first line: sed -i '1 s/\(\[directories\]\).*/\1/' /etc/asterisk/asterisk.conf At last! lets install freepbx: ./start_asterisk start ./install_amp Restart apache2 and dahdi: /etc/init.d/apache2 restart /etc/init.d/dahdi restart Finally (it seems necessary): ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3 amportal start That's all; we can connect to the management interface of or new virtual ippbx at http://ip/admin/ A reboot shows that everything works! If that is too complicated you can use a Virtual Box disk image i created here!

No comments:

Post a Comment