ryazkhan
June 12th, 2011, 02:20 AM
First of all let me say that this is not the only way to accomplish this, and there is not assurance that it will work for you. It did worked for me so I thought to share with community
Lets make yourself root otherwise you have to use sudo with each command(s) and have to type password in most cases
sudo su
Update the system and apply updates if there are any
apt-get update
apt-get upgrade
Install all dependencies
sudo apt-get install python-software-properties -y
Import public key
sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 175E41DF
Add repository so we can download asterisk 1.8
sudo add-apt-repository "deb http://packages.asterisk.org/deb `lsb_release -cs` main"
sudo add-apt-repository "deb-src http://packages.asterisk.org/deb `lsb_release -cs` main"
Update repository and install any update if needed
apt-get update
apt-get upgrade
Install Asterisk 1.8
sudo apt-get install asterisk-1.8 -y
Install DAHDI
sudo apt-get install asterisk-dahdi -y
That is it, we have sucessfully installed Asterisk 1.8
Next part is to install LAMP package
apt-get install mysql-server mysql-client apache2 php5 libapache2-mode-php5 phpmyadmin php5-mysql -y
Once done, restart all services or restart system
service asterisk restart
service mysql restart
service apache2 restart
Enjoy your new system and have fun with it
I have scripted the whole process, feel free to download it
wget http://cns.selfip.net/articles/conf/asterisk.sh
In next part we are going to set asterisk up for MySQL realtime
In this example, I am going to create two accounts and going to set them up so they can make/receive calls from each other. Both accounts will have voice mailboxes as well. I am using internal as my default context, feel free to change any setting
So lets start
Edit sip.conf file
nano /etc/asterisk/sip.conf
Add the following lines in it, the file is pretty long and has broad settings but everything is commented out of the box. Following line will set up basic operation to start and then later on you can go through the file and set the option(s) you need. You can add these lines right after [general] tag
context=internal
rtcachefriends=yes
disallow=all
allow=ulaw
allow=ilbc
Save the file and exit
Now we need to edit extensions.conf file so all use in internal context can make/receive calls
nano /etc/asterisk/extensions.conf
Add the following line right after [general] tag, again the file have broad settings but this will setup the basic context[internal]
[internal]
switch => Realtime/@
You can also add MySQL table name where all extensions are located i.e. switch => Realtime/@extensions
Save the file and exit out of it
Next we need to tell asterisk to look for MySQL database for users information
Edit extconfig.conf file
nano /etc/asterisk/extconfig.conf
Add the following lines in it, I would just add them at the end of the file
sipusers => mysql,asterisk,users ; SIP user
sippeers => mysql,asterisk,users ; SIP peers
extensions => mysql,asterisk,extensions ; SIP extensions
voicemail => mysql,asterisk,voicemails ; SIP voicemailboxes
queues => mysql,asterisk,queues ; SIP queue
queue_members => mysql,asterisk,queue_members ; SIP queue members
Now we need to tell asterisk to connect to MySQL to get all informations
So edit res_config_mysql.conf file
nano /etc/asterisk/res_config_mysql.conf
Our database for this example is asterisk so add/append the following in that file
[asterisk]
dbhost = localhost
dbname = asterisk
dbuser = mysqluser
dbpass = mysqlpass
dbport = 3306
dbsock = /var/run/mysqld/mysqld.sock
requirements=warn ; or createclose or createchar
Adjust dbuser and dbpass to your settings, this is mysql user privilage account. You can always use root for testing if you are not sure about the account
Okay at this point our asterisk box is ready and all configured !
Lastly we need to create database in mysql
So connect to mysql and create database, first import the asterisk.sql script to create database and its related tables
wget http://cns.selfip.net/articles/conf/asterisk.sql
Now connect to mysql and create the database and its table using asterisk.sql script, replace mypassword with your root's password
mysql -u root -pmypassword
source asterisk.sql;
All done!
Configure hard/soft sip phones and have fun !
As always feel free to email (mailto:ryazkhan@gmail.com) me if you have any question(s). Sorry for any typo
You can also access this article via my website (http://cns.selfip.net/articles/astrk.php) and via my blog (http://ryazkhan.blogspot.com/2011/06/asterisk-18-with-mysql-realtime-support.html)
Lets make yourself root otherwise you have to use sudo with each command(s) and have to type password in most cases
sudo su
Update the system and apply updates if there are any
apt-get update
apt-get upgrade
Install all dependencies
sudo apt-get install python-software-properties -y
Import public key
sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 175E41DF
Add repository so we can download asterisk 1.8
sudo add-apt-repository "deb http://packages.asterisk.org/deb `lsb_release -cs` main"
sudo add-apt-repository "deb-src http://packages.asterisk.org/deb `lsb_release -cs` main"
Update repository and install any update if needed
apt-get update
apt-get upgrade
Install Asterisk 1.8
sudo apt-get install asterisk-1.8 -y
Install DAHDI
sudo apt-get install asterisk-dahdi -y
That is it, we have sucessfully installed Asterisk 1.8
Next part is to install LAMP package
apt-get install mysql-server mysql-client apache2 php5 libapache2-mode-php5 phpmyadmin php5-mysql -y
Once done, restart all services or restart system
service asterisk restart
service mysql restart
service apache2 restart
Enjoy your new system and have fun with it
I have scripted the whole process, feel free to download it
wget http://cns.selfip.net/articles/conf/asterisk.sh
In next part we are going to set asterisk up for MySQL realtime
In this example, I am going to create two accounts and going to set them up so they can make/receive calls from each other. Both accounts will have voice mailboxes as well. I am using internal as my default context, feel free to change any setting
So lets start
Edit sip.conf file
nano /etc/asterisk/sip.conf
Add the following lines in it, the file is pretty long and has broad settings but everything is commented out of the box. Following line will set up basic operation to start and then later on you can go through the file and set the option(s) you need. You can add these lines right after [general] tag
context=internal
rtcachefriends=yes
disallow=all
allow=ulaw
allow=ilbc
Save the file and exit
Now we need to edit extensions.conf file so all use in internal context can make/receive calls
nano /etc/asterisk/extensions.conf
Add the following line right after [general] tag, again the file have broad settings but this will setup the basic context[internal]
[internal]
switch => Realtime/@
You can also add MySQL table name where all extensions are located i.e. switch => Realtime/@extensions
Save the file and exit out of it
Next we need to tell asterisk to look for MySQL database for users information
Edit extconfig.conf file
nano /etc/asterisk/extconfig.conf
Add the following lines in it, I would just add them at the end of the file
sipusers => mysql,asterisk,users ; SIP user
sippeers => mysql,asterisk,users ; SIP peers
extensions => mysql,asterisk,extensions ; SIP extensions
voicemail => mysql,asterisk,voicemails ; SIP voicemailboxes
queues => mysql,asterisk,queues ; SIP queue
queue_members => mysql,asterisk,queue_members ; SIP queue members
Now we need to tell asterisk to connect to MySQL to get all informations
So edit res_config_mysql.conf file
nano /etc/asterisk/res_config_mysql.conf
Our database for this example is asterisk so add/append the following in that file
[asterisk]
dbhost = localhost
dbname = asterisk
dbuser = mysqluser
dbpass = mysqlpass
dbport = 3306
dbsock = /var/run/mysqld/mysqld.sock
requirements=warn ; or createclose or createchar
Adjust dbuser and dbpass to your settings, this is mysql user privilage account. You can always use root for testing if you are not sure about the account
Okay at this point our asterisk box is ready and all configured !
Lastly we need to create database in mysql
So connect to mysql and create database, first import the asterisk.sql script to create database and its related tables
wget http://cns.selfip.net/articles/conf/asterisk.sql
Now connect to mysql and create the database and its table using asterisk.sql script, replace mypassword with your root's password
mysql -u root -pmypassword
source asterisk.sql;
All done!
Configure hard/soft sip phones and have fun !
As always feel free to email (mailto:ryazkhan@gmail.com) me if you have any question(s). Sorry for any typo
You can also access this article via my website (http://cns.selfip.net/articles/astrk.php) and via my blog (http://ryazkhan.blogspot.com/2011/06/asterisk-18-with-mysql-realtime-support.html)