open voips
Asterisk PBX
VoIP Consulting | OpenSource CRM & EMR | Asterisk PBX | VoIP Billing | Calling Card| Softswitch | CallCenter

Install CentOS & PBX

Enabling the following packages:
*DNS Server
*Web Server
*Mail Server
*MySQL Database
*Development Tools

Disable Selinux:
echo "selinux=disabled" > /etc/selinux/config

Install dependencies and extra packages:

 yum install e2fsprogs-devel keyutils-libs-devel krb5-devel libogg libselinux-devel libsepol-devel libxml2-devel libtiff-devel gmp php-pear php-pear-DB php- php-mysql php-pdo kernel-devel ncurses-devel audiofile-devel libogg-devel openssl-devel mysql-devel zlib-devel perl-DateManip sendmail-cf

cd /usr/local/src
tar zxvf lame-3.97.tar.gz
cd lame-3.97
make install

Install Asterisk and FreePBX:

 cd /usr/local/src

tar zxvf  asterisk-
tar zxvf asterisk-addons-1.4.3.tar.gz
tar zxvf  zaptel-
tar zxvf libpri-1.4-current.tar.gz
tar zxvf libpri-1.4.4.tar.gz

cd /usr/local/src/zaptel- 
make install
make config

echo "/sbin/ztcfg" >> /etc/rc.d/rc.local

cd /usr/local/src/libpri-1.4.4 
make install
cd /usr/local/src/asterisk-

Create a new user account
Use your system's preferred method of adding a new user. Examples:
  • Red Hat: adduser -c "Asterisk PBX" -d /var/lib/asterisk -u 5060 asterisk
  • Debian: addgroup --system --gid 5060 asterisk
  • Debian: adduser --system --uid 5060 --gid 5060 --home /var/lib/asterisk --no-create-home --gecos "Asterisk PBX" asterisk
  • Debian: adduser asterisk asterisk
  • Debian: adduser asterisk dialout
  • Debian: adduser asterisk audio
mkdir /var/run/asterisk
mkdir /var/log/asterisk
chown -R asterisk:asterisk /var/run/asterisk
chown -R asterisk:asterisk /var/log/asterisk
chown -R asterisk:asterisk /var/lib/php/session/

Recompile Asterisk with a new run directory

Note: Under asterisk 1.4 and later you set this in /etc/asterisk.conf after compiling
Edit /usr/src/asterisk/Makefile and change the definition of ASTVARRUNDIR like this:
Edit your Asterisk config file (/etc/asterisk/asterisk.conf):
   astrundir => /var/run/asterisk

make install
make samples

cd /usr/local/src/asterisk-addons-1.4.3 
make install
make samples

vi /etc/httpd/conf/httpd.conf

Change User apache and Group apache to User asterisk and Group asterisk.

/etc/init.d/mysqld start

cd /usr/local/src/freepbx-2.3.1

mysqladmin create asterisk
mysqladmin create asteriskcdrdb
mysql asterisk < SQL/newinstall.sql
mysql asteriskcdrdb < SQL/cdr_mysql_table.sql


GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY 'pbx';
GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY 'pbx';
flush privileges;


mysqladmin -u root password 'pbx'

Set file and directory permissions

The files in the /var/spool/asterisk/outgoing directory need to be owned by the asterisk user as well as writable. Writable because asterisk appends lines to indicate retry status. Owner so that it can set the utime. Covered below.

chown --recursive asterisk:asterisk /var/lib/asterisk
chown --recursive asterisk:asterisk /var/log/asterisk
chown --recursive asterisk:asterisk /var/run/asterisk
chown --recursive asterisk:asterisk /var/spool/asterisk
chown --recursive asterisk:asterisk /usr/lib/asterisk
chown --recursive asterisk:asterisk /dev/zap

   chmod --recursive u=rwX,g=rX,o= /var/lib/asterisk
   chmod --recursive u=rwX,g=rX,o= /var/log/asterisk
   chmod --recursive u=rwX,g=rX,o= /var/run/asterisk
   chmod --recursive u=rwX,g=rX,o= /var/spool/asterisk
   chmod --recursive u=rwX,g=rX,o= /usr/lib/asterisk
   chmod --recursive u=rwX,g=rX,o= /dev/zap

Also, make note that if you're running udev on your system (linux-2.6), the /dev directory
is dynamically populated with device nodes, meaning that any permissions you set on /dev/zap
will be lost on your next reboot, and you may get a nasty message such as "Asterisk ended with exit status 1"
when trying to start asterisk. Read the file /path/to/zaptel-src-1.2.x/README.udev for instructions on
how to change the user/group assigned to /dev/zap.
Asterisk needs read permission for these directories and their contents:
  • /etc/asterisk
chown --recursive root:asterisk /etc/asterisk
   chmod --recursive u=rwX,g=rX,o= /etc/asterisk

You might also have to take a look at the permissions of the web voicemail cgi files/directory.

Other files and devices may also need to be tweaked depending on your exact setup.

e.g. If you use chan_oss:
chown asterisk /dev/dsp

If running chan_capi for ISDN devices:
   chown asterisk /dev/capi20

If using the Sirrix cards :-
   chown asterisk /dev/bchdev /dev/dchdev

If using chan_alsa:
   chown --recursive asterisk /dev/snd

Suid executables

If you're using musiconhold with mpg123, you'll probably need to set the suid bit on the executable like this:

   chmod u+s /usr/local/bin/mpg123

this allows mpg123 to run as root even though Asterisk is running as a non-root user. This appears to be necessary for mpg123 to work properly under Asterisk.

However recall that mpg123 has some known security issues. Don't use it to play arbitrary data from the web.

Starting Asterisk

Method 1:
Starting asterisk is covered elsewhere. However once you've done the above changes, you can make sure asterisk runs as user asterisk and group asterisk by issuing this command in your startup scripts:

   asterisk -U asterisk

Method 2:

su asterisk -c /usr/sbin/safe_asterisk (buggy, see comment below)

cd /usr/local/src/freepbx-2.3.1
./start_asterisk start
./install_amp --username=asteriskuser --password=pbx
echo "/usr/local/sbin/amportal start" >> /etc/rc.local
chkconfig httpd on
chkconfig mysqld on

Open browser to http://ipaddress/admin
Click red bar in PBX

Configure Sendmail:

vi  /etc/mail/
define(`SMART_HOST', `
Save the file.
make -C /etc/mail

Edit sip_nat.conf for proper NAT:
vi /etc/asterisk/sip_nat.conf
localnet= (Set your external hostname name here)
externrefresh=10 (Set your external domain name here)

save the config file.

Add extra codecs to config:

vi /etc/asterisk/sip_custom.conf


vi /etc/asterisk/iax_custom.conf


asterisk -rx reload

Edit voicemail config:

vi /etc/amportal.conf

If the web interface on your PBX will be accessible on the internet: (Set your external hostname name here)

If the web interface on your PBX will be accessible only on your internal network: (Set your internal hostname name here)

or if your users will NOT have access to the web interface:

vi /etc/asterisk/

remove "Visit http://AMPWEBADDRESS/cgi-bin/vmail.cgi?action=login&mailbox=${VM_MAILBOX} to check your voicemail with a web browser.\n"

vi /etc/asterisk/ ; Who the e-mail notification should appear to come from
fromstring=DOMAIN PBX ; Real name of email sender

Fix MOH directory:

ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3

asterisk -rx reload

 Open browser to http://ipaddressopbx