Home > Asterisk, Freepbx > Install Asterisk1.8 on Ubuntu 10.10 Server

Install Asterisk1.8 on Ubuntu 10.10 Server

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/
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-
tar xzvf asterisk-

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.

cd asterisk-
make install

install the sample configurations:

make samples

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




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


exit 0

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;

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

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!

Categories: Asterisk, Freepbx Tags: ,
  1. Mark L
    April 24, 2011 at 2:00 pm

    Wow!.. Great stuff. I came across your site last night. I just finished an install. I’m a real noob with linux and I was able to instal it and it seems to be running. Yeh! I haven’t done this much typing since my old VAX/VMS days. but it was a great learning experince. I’m sure there are better ways to do it, but right now I’m happy. A couple of comments, as you may expect, the version number of asterisk is now at and Freepbx 2.7.0 didn’t like this version of asterisk, but there is an updated version of freePBX 2.8.1 that seems to work fine. One other thing, and perhaps i’m a noob, I had a little problem understanding the section “Now create the script that will manage the asterisk service.” For me, I didn’t totally understand what it was doing, but now that i have done it, i think i understand it… Once again, great job, and thanks for putting this guide together…


  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: