Asterisk MacOS X DB
Created by: henryjunior,Last modification on Wed 14 of Sep, 2005 [16:57 UTC]
Asterisk + Mac OS X + Database
Walkthru Guide:
Realtime Solution:- Optimistic placeholder text for the steps + info.
Non-Realtime Solution:
- Optimistic placeholder text for the steps + info.
Goal:
The purpose of this page is to serve as a place holder for a Walkthru guide that explains "how to" integrate an external Database with Asterisk under Mac OS X.MySQL would be a great first DB to consider documenting as it is shipped with OS X server (and is relatively easy to install under OS X client).
The walkthru should contain clear steps that identify:
- what needs to be installed;
- how to configure the necessary CONF files;
- some basic DB asterisk integration examples;
- a non-realtime DB solution;
- a Asterisk RealTime DB solution (when the necessary modules are working)
All of this is, unfortunately, going to need to be OS X specific...OS X is another beast all together (feel free to document the steps for how to compile myODBC and/or unixODBC under OS X!)
The steps are a bit more straight forward on other platforms because the necessary components compile smoothly, this is NOT the case under OS X.
Particular differences between installs under OS X server/client installs would be **GREAT**
To those who could offer some insight on this, I beg you to please help out, this is something that will benefit many OS X asterisk users and encourage significant development on the Mac OS X platform.

Comments
333instrucions
I'm trying to duplicate what you have done but i got problems from the begninning with the apache installation.
Could you please send me a detailed howto or links to howto to install apache 2, mysql, and php ?
i have a pb 13" 1 ghz 512 ram with mac os x 10..4.10 and xcode 2.4.1 installed.
Can you help me? i'm really interested, maybe if i succeed i can post a complete howto about it for everybody.
I have also other people interested in this.
Thanks
smaikol
333Install on Mac OS 10.4.10
The Powerbook is a G4 1.67 with 1.5GB of Ram, Tiger 10.4.10 is the installed OS, with the following Apache 2.24 compiled from source to replace Apache 1.3 that apple ship, Mysql 5.0.45 again compiled form source and PHP 5.2.3, also installed / updated are PEAR with DB & Bison. The software as i said was all compiled from source so you can guess that also installed is XCode 2.3. The location that i built the software to install into is usr/local/apache2 & usr/local/mysql and usr/local/apache2/php. Some symbolic links were made to replace the apple versions so that tiger works correctly with them in place and apachectl was also linked to the new apache2 so that i can turn it on and off from web sharing in system preferences.
Ok so with the base system out of the way here are the steps I used to get Asterisk installed on Mac OS X with the FreePBX GUI.
These are the versions of the source i got that worked, ive tried older and newer version without success.
Asterisk-1.2.17
Asterisk-addons-1.2.5
Asterisk-sounds-1.2.1
FreePBX 2.2.2
Expanded the asterisk files into three folders asterisk1217, addons125 and sounds121
Moved those three folders into /usr/local/sources/asterisk/
Open up Terminal and sudo -s Enter Admin Password
cd /usr/local/sources/asterisk/asterisk1217
make
make install
make samples
ok thats got the base asterisk installed now change folders to the addons, so we can cd.. and cd asterisk-addons-125
folow that with a make
and then a make install
and do the same for the sounds
cd..
cd asterisk-sounds-121
make install
Ok if thats all done then asterisk is fully installed and ready to go, but we want to add the freePBX GUI to it so its easier to configure. Before I do that i will just quickly fire up asterisk to make sure it loads, so asterisk -vvvvcdgi and i get nice output from asterisk in the terminal as it starts, good, now to shut it down with stop now. Excellent all working so far so good.
Next up grab the source for freePBX, i got freePBX 2.2.2 as that was the latest version on the site, Note to self try FreePBX 2.3 & check for diffs .
Now expand the freePBX tar into a /usr/local/sources/freePBX.
Before installing freePBX we need to prepare the MySQL databases it will require, the two files that have the info we want are in the SQL folder in freePBX folder,
they are cdr_mysql_table.sql and newinstall.sql
Ok I have phpmyadmin installed on my setup ( you can do it from the terminal if you want ) and i need to create to mysql databases one called asterisk and one called asteriskcdrdb, so in phpMyAdmin enter asterisk into the create database box and click create, dont worry about making a table yet just return to the index page again and make the next database called asteriskcdrdb
Next import the data from the two .sql files into the corresponding database, i prefer to do this by running a sql query as sometimes importing files can cause phpmyadmin to hang, to im going to just open the newinstall.sql file in textedit then choose select all and copy, switch over to phpmyadmin and choose the asterisk database with that selected click on the sql tab and paste the content of the newinstall.sql file into the query box, hit go and seconds later you should have 17 or so tables in that database. Now do the same for the cdr-mysql-table.sql file.
OK return to the index page of phpmyadmin as we now need to set up the correct permissions for those two databases.
create a user called asterisk with a password of your choice ( the default is AMP109 ) and grant database-specific privileges to databases asterisk and asteriskcdrdb, i also specified only localhost in the hosts allowed to connect, to secure it even further but you may or may not want to do that.
Now restart mysql.
OK so nearly ready to install freepbx, but before lets just make a note of some paths we might need, when freepbx installs it will prompt you for the location to various folders such as your httpd docs folder and the cgi-bin folder, now on tiger these are in different locations to most other systems even if your using the apple defaults, note were using apache2 and thats in a completely different location
So my www path is /usr/local/apache2/htdocs/freepbx ( the apple default is /Library/Webserver/Documents )
my cgi-bin is /usr/local/apache2/cgi-bin ( the apple default is /Library/Webserver/CGI-Executables )
and i want FOP at /usr/local/apache2/htdocs/freepbx/panel
If you want your files in a different place or you have installed apache into /opt rather than /usr/local/apache2 you will need to lookup your paths now.
ok so once you know the paths lets cd to the freepbx source and ./install_amp remember you need to be sudo so if your opening a new terminal window do a sudo -s and enter your password before ./install_amp
The first question we get asked is for the USERNAME to connect to the asterisk database, just hit enter unless you have changed if to something other than asterisk
Next enter the password you created if you didnt use the default of AMP109 otherwise just hit enter
Next just hit enter for the hostname as mysql and asterisk are running on the same machine - obviousaly if this is not the case for you then enter the correct hostname here instead.
Now for the USERNAME for the Asterisk manager interface just hit enter as were using the default - again if your not change it to what your using.
And do the same for the PASSWORD for the Asterisk manager interface.
Now comes the paths to check carefully before hitting enter,
enter the path for the AMP ( FreePBX ) web-root folder, i choose /usr/local/apache2/htdocs/freepbx as i want a folder called freepbx with all the files in it on my webserver, you can call your folder anything but get the start of the path pointing to the right place or there will be problems.
Next enter the IP address of the machine, mine has a static address of 192.168.25.130 so i could enter that but im going to enter the localhost address of 127.0.0.1 just incase i want to change my actual ip later. you could also just enter localhost or even powerbook.local or whatever you hostname is.
Now enter a flash operator panel password or leave it set to the default of passw0rd by hitting enter, i hit enter
Next hit enter to accept extensions ( this way phones and users are administered from the same page )
Again hit enter to store the exe’s in the /var/lib/asterisk/bin or change it if you want it elsewhere, again im hitting enter to use the default.
Do the same for super-user scripts at /usr/local/sbin just hit enter
FreePBX should now install, there will be a few permission errors at the end of the install but dont panic freepbx is installed and well fix the errors in a moment.
Ok so in the finder do a get info on your freepbx web root mine is /usr/local/apache2/htdocs/freePBX in the Ownership & Permissions section of the Info window set the Owner to your user accound and set read & write as the Access level, set the Group to WWW and the Access to read & write and set Others to read & write.
Ok so thats not very secure, but without changing apache to run as a different user and running into a bunch of other problems ( that i’ve experenced over the last year playing with this stuff ) im happy with that as my machine can only be access locally anyway.
Repeat those permission and owner settings for the following files and folders
/var/lib/asterisk - and choose Apply to enclosed items at the bottom of the info window
/var/spool/asterisk - and choose Apply to enclosed items at the bottom of the window
/etc/amportal.conf
/etc/asterisk - and choose Apply to enclosed items at the bottom of the windownow in the terminal goto /var/lib/asterisk/bin and chmod 777 *.pl this sets all the perl files to executable, and also chmod 777 retrieve_conf , to make that file executable too.
/var/lib/asterisk/agi-bin - and chmod 777 dialparties.agi and recordingcheck.agi
now execute ./retrieve_conf to make those files that the permission was denied for just a moment ago when we ran the install_amp script.
Now fire it up asterisk -vvvvcgdi
and in safari http://localhost/freePBX
So there is only one problem remaining in that clicking the red bar does not reload the configuration file - for some reason retrieve_conf is not being executed so remember to manually run that after making changes in the freePBX interface. when i find a solution to that last problem i will post it here.
But for now
Success ! A working system.
333Mysql & Asterisk
Asterisk talks to mysql nicely and does real time loggin etc - Im on OS X on both PPC & Intel and have compiled from source Asterisk and ARI without a hitch just by following
the guides on this site for other linux variants.
Next up is installing FreePBX-or similar in Mac OS X