a2billing 14 Installation Guide 1.0

download a2billing 14 Installation Guide 1.0

of 12

Transcript of a2billing 14 Installation Guide 1.0

  • April2009a2billing1.4InstallationGuide Version1.0

    INSTALLATIONGUIDE1.0

    [email protected]@it46.se

    (cc)CreativeCommonsShareAlikeNonCommercialAttribution3

    ThisguidefocusesontheinstallationofabillingsystemfortheAsteriskopensourcePBX.Thedocumentcoverstheinstallationofa2billing.A2billingisanopensourceimplementationofatelecommunicationbillingandaddedvalueservicesplatform.1

    A2billingisaLAMP(LinuxApacheMysql(Postgresql)PHP)applicationthatinterfaceswithAsteriskusingboththeAMIandAGIinterfaces.

    Thisdocumenthasbeentestedafterusinga2billingtrunkwithDebianetch,Debianetchandhalf,Ubuntu8.04andUbuntu8.10.(27thMarch2009)

    1 http://www.asterisk2billing.org

    1(12)

  • April2009a2billing1.4InstallationGuide Version1.0

    TableofContentsPART1.SoftwareRequirements...........................................................................................2

    Importantnoteaboutdistributions...................................................................................2LinuxRequirementsanda2billing......................................................................................3Notgettinglost,whatistheinstallationabout?...............................................................3Howallfitstogether?.........................................................................................................4

    PART2.Installationofa2billing............................................................................................5STEP1.GetA2Billingsourcecode...................................................................................6STEP2.PreparetheDatabase..........................................................................................6STEP3.Edita2billingconfigurationfile...........................................................................7STEP4.Fixpermissions,filesandfolders.......................................................................8

    1.SIPandIAX..............................................................................................................82.Soundfiles..................................................................................................................83.ConfigureAsteriskManager......................................................................................8

    STEP5.InstallTheAGIcomponents..............................................................................9STEP6.InstallwebbasedGraphicalinterfaces...............................................................9STEP7.Createdialplan..................................................................................................10STEP8.Configurerecurringservices..............................................................................11STEP9.Callbackdaemon(onlyforCallbacks)...........................................................12

    PART3.DefaultpasswordsandURL..................................................................................12

    PART1. SOFTWAREREQUIREMENTS

    IMPORTANTNOTEABOUTDISTRIBUTIONS

    Thisdocumentationassumesthatyouareusinga.debbasedLinuxdistrothathasusedthefolder/usr/share/asteriskduringasteriskpackaging.

    Otherdistributionsusethealternatefolder/var/lib/asterisk.Thatisthecaseifyoucompilefromsourcethepathbydefaultis/var/lib/asterisk.

    Thebasicassumptionsofthisdocumentationisthatyouarenotcompilinganyofthesoftwarepackagesforsource.

    Otherassumptionsare:

    yourapache2defaultrootfolderis/var/www yourasterisksoundsareunder/usr/share/asterisk/sounds yourasteriskAGIfolderisexpectedunder/usr/share/asterisk/agibin

    2(12)

  • April2009a2billing1.4InstallationGuide Version1.0

    yourapache2runsaswwwdata(uid) youasteriskrunsasasterisk(uid) thoseusingsubversiontocheckoutthecode,arerecommendedtousesymboliclinks

    insteadofcopyingthefilestotherightdirectories

    LINUXREQUIREMENTSANDA2BILLING

    a2billing1.4includesthefollowingthirdpartysoftware:

    phpagi2.14Copyright2003,2004,2005MatthewAshamandDavidEder smarty2.6.22Copyright20012005NewDigitalGroup,Inc jgraph1.27Copyright2001,2002,2003,2004JohanPerssonAditusConsulting adodb4.991Copyright(c)2000,2001,2002,2003,2004JohnLim html2pdfCopyright(C)20042005RenatoCoelho famfamfam.comIconsfromMarkJames phpconfig(C)2003DavePackhamandRobBirkinshaw

    NOTGETTINGLOST,WHATISTHEINSTALLATIONABOUT?

    Inanutshellinstallinga2billingrequiresninesteps:

    1. Downloadandunpacksourcecode2. Setupthedatabase3. Edita2billing.conffile.Settingupthedatabaseparameters4. Fixpermissionsandfolders5. Installingthewebbasedgraphicaluserinterfaces(CustomerandAdmin)6. PlacetheAGIfiles7. Prepareyourdialplan8. Addyourcronjobs9. Configureyourcallbackdaemon(onlyforcallback)

    Tohelpyoutounderstandwhatwearedoingconsiderthat:

    1. Themotherofallcomponentsofa2billingisanAGIfile(a2billing.php)thatiscalledfromasteriskdialplan.(SeeStep:6,7)

    2. TheoverallgoaloftheinstallationistomakesurethattheAGIfilethatisplacedintheasteriskagibinfolderandinvokedfromthedialplancan(1)accessamysqldatabaseand(2)connecttoAsteriskmanagertoplaceandreceivecallrelatedcommandsandinformation.(SeeStep:2,3,4)

    3(12)

  • April2009a2billing1.4InstallationGuide Version1.0

    3. A2billingismanagedviathreedifferentuserinterfaces(admin,agentandcustomer)thatneedstorunviatheapache2webbrowserwiththerightownerandpermissions(SeeStep:5)

    4. Thereareothercomponentsascronjobs,callbackdaemon,etcthatareneededforadvanceaddedvalueservices(SeeStep:8,9)

    HOWALLFITSTOGETHER?

    A2billingisacomplexsoftwarebutthemainideacanbesummarizedasfollows:WhenacallcomesintoAsterisk,itfallsintoacontext(apartofthedialplan)thatwillexecutea2billing.phpPHPfileinoneofitsoperationalmodes.ThePHPfileistheAGI(AsteriskGatewayInterface)softwarethatisresponsibleofretrievinginformationofthecallfromtheAMI(AsteriskManagerInterface)andinteractwiththeMysqldatabase.Allactionsrelatedtothecall(routing,playingaIVR,etc)areexecutedtalkingtoAsteriskviatheAMI.

    a2billing.php(theAGIcodeinthedialplan)usesaPHPclassknownasphpagitotalkwiththeAMIandadodbtoconnectwiththemysqldatabase.Toseparatefunctionalityfrompresentationa2billing1.4isusingsmarty.

    4(12)

  • April2009a2billing1.4InstallationGuide Version1.0

    PrerequiredPackagesA2billingrequiresthepackagesofaLAMP(PHP5)installation.

    Toinstallthenecessarypackages,runthefollowingcommands:

    #aptgetinstalllibapache2modphp5php5php5common#aptgetinstallphp5cliphp5mysqlmysqlserverapache2php5gd#aptgetinstallopensshserver

    Version1.4requiresMcryptforPHP5#aptgetinstallphp5mcrypt

    Asteriskisofcoursealsoneeded.#aptgetinstallasterisk

    PART2. INSTALLATIONOFA2BILLING

    Inanutshellinstallinga2billingrequiressevensteps:

    1. Downloadandunpacksourcecode

    2. Setupthedatabase

    3. Edita2billing.conffile.Settingupthedatabaseparameters

    4. Fixpermissionsandfolders

    5. PlacetheAGIfiles

    6. Installingthewebbasedgraphicaluserinterfaces(Customer,AgentandAdmin)

    7. Prepareyourdialplan

    8. Addyourcronjobs

    9. Configureyourcallbackdaemon(onlyforcallback)

    5(12)

  • April2009a2billing1.4InstallationGuide Version1.0

    STEP1. GETA2BILLINGSOURCECODE

    Downloadthesourcecode(wget)andunpackit(tar).2

    #cd/usr/local/src/#wgethttp://www.asterisk2billing.org/downloads/A2Billing_1.4.0.tar.gz#tarzxvfA2Billing_1.3.4.tar.gz

    Wewillnowcreateasymboliclinktothenewdirectory#lns/usr/local/src/a2billing_1.4.0/usr/local/src/a2billing

    Makesureyouhaveallthecodeunder/usr/local/src/a2billing

    STEP2. PREPARETHEDATABASE

    WewillnowcreateaMySQLdatabase(mya2billing)forthebillingsoftware.Thefilea2billingMYSQLcreatedbuser.sqlincludesascriptthatcreatesthedatabasewiththecorrectaccesscontrolusersandpermissions.

    #cd/usr/local/src/a2billing#mysqlurootpexit

    2 IfyouareadeveloperconsiderusingtheSVNversionsvncousernameguestpasswordguesthttp://svn.a2billing.net/svn/asterisk2billing/trunk

    6(12)

  • April2009a2billing1.4InstallationGuide Version1.0

    STEP3. EDITA2BILLINGCONFIGURATIONFILE

    WeneedtoedittheA2Billingconfigurationfile(a2billing.conffile).ThefilecontainsalltheconfigurationinformationfortheAsterisk2Billingtoconnecttothedatabase.

    First,weneedtocopythedefaultconfigurationfilefromthesourcecode(/usr/local/src)toAsterisk(/etc).Noticethatinpreviousversionsthea2billing.confwasunder/etc/asterisk

    #cp/usr/local/src/a2billing/a2billing.conf/etc/

    Openthefilewithyourfavoritetexteditor(viisusedinthisexample).IfyouarenewtoLinux,werecommendyoutousethetexteditorGedit3.

    #vi/etc/asterisk/a2billing.conf

    Theonlyparametersthatyouneedtochangehereisthedatabaseconnectioninformation,anexamplefollows:

    [database]hostname=localhostport=3306user=a2billinguserpassword=a2billingdbname=mya2billing;dbtype=postgresdbtype=mysql

    3 Geditisagraphicaltexteditorandcannotberunfromaconsole.Inthatcase,werecommendvi.

    7(12)

  • April2009a2billing1.4InstallationGuide Version1.0

    STEP4. FIXPERMISSIONS,FILESANDFOLDERS

    Inthisstep,wewilltweakthefilepermissionsofAsterisktofittheA2Billingsoftware.WewillalsocreateanumberofadditionalfilesandfoldersthatA2Billingneeds,whichdoesnotcomewiththedefaultinstallation.

    1. SIPandIAX

    Firstwewillsetafewfilepermissions(chmod,chown)andcreate(touch)theSIPandIAXconfigurationfilesforAsterisk.

    chmod777/etc/asterisktouch/etc/asterisk/additional_a2billing_iax.conftouch/etc/asterisk/additional_a2billing_sip.confecho\#includeadditional_a2billing_sip.conf>>/etc/asterisk/sip.confecho\#includeadditional_a2billing_iax.conf>>/etc/asterisk/iax.confchownRfwwwdata/etc/asterisk/additional_a2billing_iax.confchownRfwwwdata/etc/asterisk/additional_a2billing_sip.conf

    2. Soundfiles

    Weneedtocopy(cp)afewfilesfromA2BillingpackagetoAsterisksoundsfolder.Usetheinstallationscriptasfollows:

    /usr/local/src/a2billing/addons/install_a2b_sounds_deb.shchownRasterisk:asterisk/usr/share/asterisk/sounds/

    3. ConfigureAsteriskManager

    ConfiguretheAsteriskManagerbyeditingthemanager.conffile.

    #vi/etc/asterisk/manager.conf[general]enabled=yesport=5038bindaddr=0.0.0.0

    [myasterisk]secret=mycoderead=system,call,log,verbose,command,agent,userwrite=system,call,log,verbose,command,agent,user

    8(12)

  • April2009a2billing1.4InstallationGuide Version1.0

    STEP5. INSTALLTHEAGICOMPONENTS

    PlacetheentirecontentofthedirectoryAGIintoyouragibindirectory.

    mkdir/usr/share/asterisk/agibincd/usr/local/src/a2billing/AGIcpa2billing.php/usr/share/asterisk/agibin/cpRflib/usr/share/asterisk/agibin/

    Makesurethescriptisexecutablechmod+x/usr/share/asterisk/agibin/a2billing.php

    STEP6. INSTALLWEBBASEDGRAPHICALINTERFACES

    Inthisstep,wewillinstallthethreegraphicalinterfacesofA2Billing,theAdministration(admin),Agent(agent)andtheCustomerinterface(customer).

    Placethedirectoriesadmin,customer,agentandcommonintoyourwebserverdocumentroot.

    mkdir/var/www/a2billingcprf/usr/local/src/a2billing/admin/var/www/a2billingcprf/usr/local/src/a2billing/agent/var/www/a2billingcprf/usr/local/src/a2billing/customer/var/www/a2billingcprf/usr/local/src/a2billing/common/var/www/a2billing

    chmod755/var/www/a2billing/admin/templates_cchmod755/var/www/a2billing/customer/templates_cchmod755/var/www/a2billing/agent/templates_c

    chownRfwwwdata:wwwdata/var/www/a2billing/admin/templates_cchownRfwwwdata:wwwdata/var/www/a2billing/customer/templates_cchownRfwwwdata:wwwdata/var/www/a2billing/agent/templates_c

    Restartyourwebserver(Apache).

    /etc/init.d/apache2restart

    Checkpoint2:Directabrowsertotheadministrativewebinterface(http:///a2billing/admin)andlogin(checkforalldefaultpasswordsattheendofthisdocument).

    9(12)

  • April2009a2billing1.4InstallationGuide Version1.0

    STEP7. CREATEDIALPLAN

    Theextensions.confistheAsteriskdialplan.Callsthatinteractwiththebillingsoftwareneedtobehandledinsideofoneormanya2billingrelatedcontexts.

    Thecallsthatreachthecontextareprocessedusingthea2billing.phpAGIscript.Thea2billing.phpscriptcanbeinvokedinmanydifferentmodes(standard,did,voucher,callback,etc).Intheexample,wecreatetwodifferentcontexts,thefirstcontext[a2billing]handlesallthecallsfromourVoIPclients.Whenacallarrives,anyextensionnumber_X.(2digitsormore)reachesthescripta2billing.php

    Thesecondcontext[did],willbeusedtorouteincomingcallsbacktotheusers.Callstotheclients(DID)arehandledinsideofthe[did]context.Thescripta2billing.phpindidmodeisresponsibleofroutingthecallbacktooneofourusers.4

    Editextension.conf(/etc/asterisk)andaddthefollowingtwoextensions.

    [a2billing];CallingCardapplicationexten=>_X.,1,Answerexten=>_X.,2,Wait,2exten=>_X.,3,DeadAGI,a2billing.phpexten=>_X.,4,Wait,2exten=>_X.,5,Hangup

    [did];CallingCardapplicationexten=>_X.,1,DeadAGI(a2billing.php|1|did)

    4 DeadAGIisavariantofAGIthatyouusewhenthechannelishungup.

    10(12)

  • April2009a2billing1.4InstallationGuide Version1.0

    STEP8. CONFIGURERECURRINGSERVICES

    Recurringservicesarehandledviathe/etc/crontab

    Youcanaddthefollowingcronjobstoyour/etc/crontaborcreateafilewiththejobsin

    /var/spool/cron/a2billing

    #updatethecurrencytable06***php/usr/local/src/a2billing/Cronjobs/currencies_update_yahoo.php

    #managethemonthlyservicessubscription061**php/usr/local/src/a2billing/Cronjobs/a2billing_subscription_fee.php

    #TocheckaccountofeachUsersandsendanemailifthebalanceislessthantheuserhavechoice.0****php/usr/local/src/a2billing/Cronjobs/a2billing_notify_account.php

    #Tocheckalltheaccountsandsendannotificationemailifthebalanceislessthanthefirstargument.0*/6**php/usr/local/src/a2billing/Cronjobs/a2billing_check_account.php

    #thisscriptwillbrowsealltheDIDthatarereserveandcheckifthecustomerneedtopayforit#billthemorwarnthemperemailtoknowiftheywanttopayinordertokeeptheirDIDs02***php/usr/local/src/a2billing/Cronjobs/a2billing_bill_diduse.php

    #Thisscriptwilltakecareoftherecurringservice.012***php/usr/local/src/a2billing/Cronjobs/a2billing_batch_process.php

    #Togenerateinvoicesandforeachuser.06***php/usr/local/src/a2billing/Cronjobs/a2billing_invoice_cront.php

    #toproceedtheautodialer*/5****php/usr/local/src/a2billing/Cronjobs/a2billing_batch_autodialer.php

    #managealarms0****php/usr/local/src/a2billing/Cronjobs/a2billing_alarm.php

    11(12)

  • April2009a2billing1.4InstallationGuide Version1.0

    STEP9. CALLBACKDAEMON(ONLYFORCALLBACKS)

    Thecallbackdaemonisresponsibleofreadingfromthedatabasethepoolofcallsstoredforcallbackandtriggerthosecallsperiodically.ThedaemoniswritteninPython.Installthepythonsetuptoolsanduseeasy_installtoinstallthecallback_daemon

    aptgetinstallpythonsetuptoolspythonmysqldbpythonpsycopg2pythonsqlalchemycd/usr/local/src/a2billing/CallBackeasy_installcallbackdaemonpy/dist/callback_daemon1.0.prod_r1527py2.5.eggInstalltheinit.dstartupscript

    cd/usr/local/src/a2billing/CallBack/callbackdaemonpy/callback_daemon/cpa2bcallbackdaemon.debian/etc/init.d/a2bcallbackdaemonchmod+x/etc/init.d/a2bcallbackdaemon

    Makesurethedaemonstartsupdaterc.da2bcallbackdaemondefaults4060

    Ifyouneedtoremovethedaemoninthefuturerunupdaterc.dfa2bcallbackdaemonremove

    PART3. DEFAULTPASSWORDSANDURLType Username Password Database

    AdminUI root changepassword

    Manager myasterisk mycode

    MySQLdatabase a2billinguser a2billing mya2billing

    Note!Thefirstcharacterinallusernamesandpasswordsisasmallletter(notcapital).

    12(12)

    PART 1. Software Requirements Important note about distributionsLinux Requirements and a2billingNot getting lost, what is the installation about?How all fits together?

    PART 2. Installation of a2billingSTEP 1. Get A2Billing source codeSTEP 2. Prepare the DatabaseSTEP 3. Edit a2billing configuration fileSTEP 4. Fix permissions, files and folders 1. SIP and IAX2. Sound files3. Configure Asterisk Manager

    STEP 5. Install The AGI components STEP 6. Install web-based Graphical interfaces STEP 7. Create dialplanSTEP 8. Configure recurring servicesSTEP 9. Call back daemon (only for Call backs)

    PART 3. Default passwords and URL