Asterisk
Aserisk/FreePBX/MySQL/CentOS 5.1/VOIP (no FXO - FXS)
./configure
if it returns a “0″, then, you’re ok to go, there were no errors while running. However, if there was a non-zero, then you have some problems, and should go back to find out what they were. I’ll be using it from time to time, and so should you.
I have scoured the internet for a good tutorial/walk-thru on installing Asterisk with FreePBX and MySQL. And, I will admit, I’m not impressed. There were many sites that were useful, with either terminology, or getting one thing working. But, not a single one of them were able from start to finish, get a fully functioning Asterisk/FreePBX/MySQL/CentOS system working. In my tutorial, I plan to do just that. I hope this will help many people, including myself. There are some things, however, I will tell you from the start, I, myself, am quite new to Asterisk. I’m still learning how to use all of its capabilities. I will be installing Asteisk as “root” user, meaning, Asterisk will be running as “root” user (not security conscious). Eventually, when I feel comfortable enough with Asterisk, I will do a install not running as “root”.
I will walk you through the installation of CentOS 5.1, then Asterisk, Asterisk-Addons, and finally FreePBX. Also, in the next week or two, I will have a video-cast, on this same install procedure. So, keep tuned.
I will like to say, if you sway away from this tutorial, or do things differently, it may not work. If you follow it to the “T”, it will work. It is tried, and tested.
A command I like to use regularly, specially when I make and make install a program, I like to run the “echo $?” command. Which, in turn tells you if whether there were any errors while running the make command for example:
echo $?
So, let’s get started.
|
CentOS Dowloads Save it to your machine, and burn it with your favorite burning software, such as Nero. Start up your server, with your newly burned DVD. You may need to go into BIOS, and make sure your system boots with the DVD.
System Tools That wasn’t painful, was it. Next, we’re going to update the system, install whatever the installation didn’t install for us, and then have some fun installing Asterisk, yahoooooooooooooooo!!! |
Prepare ↓↑ our new CentOS system…
|
Unless you prefer to work at the terminal of your physical server, you’re going to need some sort of SSH software you can use remotely. Apparently, the most used one is Putty, however, I prefer to use BitVise Tunneler. Following this tutorial, you’ll definitely prefer using a SSH program, so, you can just copy and paste in the command, instead of typing them all in. First thing is first, let’s disable Selinux. I must admit, disabling Selinux is a tad trivial. You would think, if you edit /etc/selinux/config, setting the selinux=disabled, and then restarting the network would disable it. But, nope! Or even, typing at the prompt, selinux=disabled would stop selinux, nope. You actually have to run:
Now, let’s run a: yum -y update
this is going to take some time, so, get yourself a well deserved tea, go spend some time with the kids, and don’t forget, give the wifey a kiss. reboot Alrighty, our system is updated, and SeLinux is disabled. Let’s now install some much needed software that Asterisk and FreePBX needs so our install goes nice and smoothly without a hitch.
yum -y install bison ncurses ncurses-devel openssl gcc libtermcap \ If you had any YUM problems, namely “yum error: Cannot find a valid baseurl for repo: core”, do the following. vi /etc/yum.repos.d/CentOS-Base.repo
And, delete all the “#” in front of baseurl. That should do it. Oddly, even though we ran the “yum -y install previously, I was getting some errors running the below command, so, run this first before we proceed:
yum -y install libtermcap-devel
Let’s now download some software we’re going to need, unfortunately, I don’t have the exact “wget” url, so you’re going to have to download them the ol’ fashioned way, and upload them to your server. So, in your web browser, add this: Upload that to your /usr/src directory on your sever. And, now, let’s go to our server: cd /usr/src while we’re there, let’s download another tarball. wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz Let’s untar those guys and install them:
tar xzvf mpg123-1.4.3.tar.gz Now, I’m not sure if this is necessary, but, I read somewhere that Named (DNS) needs to be running for Asterisk to behave. If I’m wrong, please let me know, otherwise, I installed it, and everything seems to be working. Until I’m corrected, I’m going to live by the, “if ain’t broken, don’t fix it” attitude. So, let’s setup Named. Also, another thing I noticed, since I’m no HTML expert, when you copy and paste from my page, it doesn’t get copied properly to your command prompt. So, after pasting the following into your terminal, I recommend opening up /etc/named.conf, and editing it to make sure everything is proper.
That wasn’t hard, was it? Alright, now let’s make sure, Named, Apache and MySQL run at startup.
chkconfig named on Alright, let’s start some of those services, as well as run pear.
service httpd start If you got an error starting the DNS (named) service. Just edit /etc/named.conf so it looks exactly like the following:
options { Save the file, and again, run: service named start Oh, by the way, one thing I really like to do when I install a new system, is run the command: updatedb this, updates the database for the “locate” command. So, later on, when we don’t know where a particular file is, we can run: locate httpd.conf for example, and, it will give you a listing where that file(s) is. Now may be a good time to reboot our system, we’ve made quite a few changes. So, let’s restart: reboot Alright, let’s make sure some of our services started, shall we.
service httpd status make sure, each and every one of them started. If not, don’t go further, and figure what is wrong. |
Asterisk ↓↑ and Asterisk Addons install…
|
Alrighty, let’s start with the Asterisk part of the install. This is where the fun starts. Let’s add the asterisk user, and create some directories that are needed by asterisk, and the permissions for those directories:
useradd -c “Asterisk PBX” -d /var/lib/asterisk asterisk Let’s now download, untar, and install Asterisk, and Asterisk-Addons:
cd /usr/src tar -xzvf asterisk-1.4-current.tar.gz
mv asterisk-1.4.21.2/ asterisk
cd asterisk && ./configure && make menuselect Basically, what we did there, is ran the make menuselect, which allows you to install extra feature such as which sound formats your prefer, such as, wav, gsm, g729 etc… When, you finished with menuselect, be sure to press “s” to save and exit then run the make command. The make config installs the startup files so asterisk loads upon boot, and make samples creates sample config files such as, sip.conf and extensions.conf to name a couple. And now, let’s do the same for Asterisk-Addons:
cd /usr/src/asterisk-addons && ./configure && make menuselect
Alright, now, we have Asterisk and Asterisk-addons installed. Let’s now finish up, so we can start using our brand spanking new Asterisk server. Admit it, you’re kinda excited, it’s ok, smile:).
mysqladmin -u root password ‘password‘ To be on the safe side, I usually like to connect to MySQL after, just to be sure, my 2 databases I just created were indeed created, and, while I’m in there, do some cleaning up, namely, delete some unneeded DB’s. mysql -u root -p lol, enter your password. My gosh, I’m being nice!!! show databases; Make sure, our 2 newly created DB’s are there (asterisk, and asteriskcdrdb). Also, you should see (test) database there, which we really don’t need. It’s also, a security thingy. So, let’s delete it:
drop database test; Guess what, we’re almost there, promise! Let’s set up some Apache files so it plays nicely with FreePBX. vi /etc/httpd/conf/httpd.conf Find user apache and group apache, and change them to:
user asterisk Press the “esc” key, then colon and then “w” and “q” for (write and quit), you should see, on the bottom left hand corner “:wq” then hit enter. Now, let’s edit: vi /etc/asterisk/asterisk.conf and, change astrundir from /var/run, to: astrundir => /var/run/asterisk save, and exit. And, now, we’re going to edit /etc/php.ini. vi /etc/php.ini and change the following:
post_max_size = 20M Let’s restart Apache with the following command: service httpd restart Let’s start Asterisk, and change some more permissions.
service asterisk start Finally, let’s download FreePBX, and copy over our databases information from FreePBX.
svn co https://amportal.svn.sourceforge.net/svnroot/amportal/freepbx/branches/2.3/ /usr/src/freepbx Be careful with the ./install_amp command. I’m going by memory here, but, it’s going to ask you a few questions. Make sure you put in your password(lol). And, just in case, you get a problem with that, then run: ./install_amp username=asterisk password=password Oh, and, just in case you forgot your username, do a: cat /etc/amportal.conf | grep AMPDBNAME Also, let’s change a few more things.
vi /var/www/html/recordings/includes/main.conf.php Let’s create or sip_nat.conf file. But, considering I’m as well a newbie, this is completely up to you. But, if you skip this part, that’s your call. With everything above, you should have a mean, lean fighting Asterisk server up and running. But, follow along anyhoops, and you can later go and change these things.
vi /etc/asterisk/sip_nat.conf And, let’s create our sip_custom.conf file to add our extra codecs:
vi /etc/asterisk/sip_custom.conf
vi /etc/asterisk/iax_custom.conf asterisk -rx reload
vi /etc/amportal.conf or if your users will NOT have access to the web interface: vi /etc/asterisk/vm_email.inc 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/vm_general.inc ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3 asterisk -rx reload Goto your browser And, that should do it. You should now have everything up and running. Oh, but, you will have to install the modules. Alright, the first thing you’re going to need to do is click on the red line above. But, that’s simple as pie. Where does that expression come from. Has anyone ever made a pie before. It’s actually hard to bake a pie. Anyhoops, I hope anyone who has read this, enjoyed it, and was able to follow along easily. And, hopefully, it worked. Please, and, I say please, feel free to contact me if there are any questions, or errors in my setup. |
|
Ok, we have created and installed our CentOS system, installed Asterisk, MySQL and FreePBX. They’re all talking nicely to each other. Let’s make our new system do some work for us, shall we. First thing we’re going to do, is install some modules. Without modules, Asterisk and FreePBX is useless to us.
I’m not going to go through each one with you. But, we will go through installing one together, then after that, you can install whatever your little heart desires. As you can see, there are tons to choose from. So, let’s choose one, that you will most definitely want. I know, I know, that’s a ton of stops, just to install a module. But, hey, at least you now have a running Asterisk box. Now, install all the modules you’ll want. One last thing, for some reason, I couldn’t get FOP to work. But, I finally found out how to get it going, at the CLI, type in the following command: amportal start_fop
and that should do it. |