How to upgrade Asterisk
[b]How to upgrade Asterisk[/b]
[b]Note:[/b] Doing this improperly may break your system, so I don't recommend doing this unless you have a complete backup and know how to fix what you break.
[b]Note 2:[/b] Do NOT just upgrade to the very latest version of Asterisk unless you are CERTAIN that version works with FreePBX. If you are using an older version of FreePBX (2.2.x or earlier) you should not even consider upgrading to the 1.4 branch of Asterisk. Instead, use the latest Asterisk version in the 1.2 branch. On the other hand, if you are using a current FreePBX version (2.3.x or later), you may be able to use a version of Asterisk in the 1.4 branch. The instructions below assume that you are sticking with the 1.2 branch of Asterisk for the time being.
[b]Note 3:[/b] Users of "all in one" distributions (such as AsteriskNOW, Elastix, PBX in a Flash, etc.) should be aware that that the preferred method for upgrading your distribution may be to use an upgrade script, or some other method specific to your distribution. You may want to peruse the forums specific to your distribution before proceeding. Note that upgrading using the method shown here could cause some distribution-specific features to stop working - if that happens, it's your responsibility to figure out what to do to get those features working again. Also, it's possible that the kernal source code may not have been included the distribution you are using, and it is needed to successfully compile Asterisk, so if you need the kernal source you may to do [b][i]yum -y install kernel-devel kernel[/i][/b] from the command prompt prior to continuing with these instructions. If you do choose to use the procedure shown here rather than the one specific to your distribution, and then at some later date you run a distribution-specific upgrade script, you may in fact revert some of the software to an older version.
That said, here is the best information I have found on upgrading Asterisk. Before you do this, you may want to use your web browser to navigate to the following directories to see if there are later versions[b] in the same branch[/b] as the version shown below - if so, you may want to try the newer version:
http://downloads.asterisk.org/pub/zaptel/releases/ (if using dahdi rather than zaptel: http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/releases/)
(libpri is really only necessary if you have a T1, but it may already be installed on your system and if so, you probably want to update it.)
From the command prompt, execute each of the following commands, in turn, from the command line (substituting the latest version [b]in the same branch[/b] if you wish, and substituting dahdi for zaptel if your installation uses dahdi - the author of this document has no experience with dahdi, so cannot advise you beyond that):
tar -xzvf ./asterisk-1.2.32.tar.gz
tar -xzvf ./zaptel-1.2.27.tar.gz
tar -xzvf ./libpri-1.2.8.tar.gz
tar -xzvf ./asterisk-addons-1.2.9.tar.gz
tar -xzvf asterisk-sounds-1.2.1.tar.gz[/code]
Prior to compiling you need to remove the old modules, but rather than just blowing the directory away, I'd suggest renaming it to a backup - there might be some added modules in there that you will want to restore later, e.g. codecs you may have added. Note that making some of these modules unavailable may be the cause of certain third-party applications "breaking", which I why I don't advise just deleting everything.
mv modules ./old-modules-backup[/code]
If you have never done it previously (and particularly if you are not installing a fairly recent distribution), you may need to grab an updated version of the spinlock.h file from the Nerd Vittles site. If you are simply upgrading from a earlier version of Asterisk you probably don't need to do this, but I'll mention it anyway (definitely take a look if you are having problems with Zaptel). See the Nerd Vittles article at either http://nerdvittles.com/index.php?p=137 or http://nerdvittles.com/index.php?p=174 (search the page for "spinlock.h").
Now compile and install (note the directory names will be different if you installed different versions):
[b]Note:[/b] If you are running a Rhino Zaptel PCI Card like the R4FXO, please see the comment by WAudette at the bottom of this page [b]before[/b] proceeding with the next step.
Note: If you are using the Open Source Line Echo Canceller (OSLEC) then you will want to patch Zaptel [b]before[/b] running [b]make[/b]. See this page and look for the section heading "HowTo - Run OSLEC with Asterisk/Zaptel."
[b]Note: [/b]If the Zaptel compile fails during "make", run the following from the command line:
sed -i s/rw_lock/rwlock/ /usr/src/kernels/*/include/linux/spinlock.h
Then rerun "make" and "make install". One person said the above line didn't work for him, but this one did:
sed -i s/rw_lock/rwlock/ /usr/include/linux/spinlock.h
Anyway, once you get the Zaptel upgrade installed, you can continue...
Note: "make clean" and "make" are not required for the sounds module.
(The "make clean" instructions above may not always be necessary, strictly speaking, but they don't hurt anything and in a few cases may help avoid problems.)
After doing the above, you may want to compare the contents of /usr/lib/asterisk/modules and /usr/lib/asterisk/old-modules-backup, and copy over any files that are in the backup directory but not the new modules directory. Some modules I found that had not been reinstalled included:
Your list may be different. Note that simply copying these modules back does not automatically guarantee that everything will start working again, but it probably improves your odds considerably. Be careful NOT to overwrite anything in the new modules directory!
Note that on rare occasions, Asterisk may fail to restart after you upgrade (this was a particular issue starting with version 1.2.16 and continuing for perhaps a couple of versions thereafter, but has not been frequently noted in the most recent versions). If that happens, don't panic! Instead, enter the following at the command prompt:
This will show you the last few lines of the log file, and will (hopefully) reveal what Asterisk was attempting to load when it failed. How you handle it depends on the exact nature of the problem, but the typical problem seems to be that Asterisk fails to load a module, such as a codec - for example, I had a problem where Asterisk refused to load the codec_speex.so module. Since I don't use the speex codec anyway, I simply moved the module out of the usual location (the /usr/lib/asterisk/modules directory) into another location, and restarted Asterisk. When Asterisk couldn't find the offending codec, it moved on and restarted normally. The creator of the Nerd Vittles site had a problem with the app_speech_utils.so module; you can read about his experience and solution here (look for the section headed "Fixing a Source Code Wrinkle").
After removing the incompatible module, you may get a message such as "Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)" when you attempt to restart Asterisk. Simply deleting the asterisk.ctl file does not seem to help. Probably the easiest way to resolve this problem is to simply reboot the system (use [b]shutdown -r now[/b]), after which Asterisk will (hopefully) come back up and operate normally (if anyone knows a better way, please feel free to edit this paragraph - I know that in theory one should hardly ever need to reboot Linux, but in this case Asterisk is already non-functional and rebooting seems to get it to restart properly, and IMHO a reboot after a upgrade is an easy way to end any running processes that might benefit from being restarted anyway).
The Nerd Vittles site suggests that you may need to rebuild Zaptel after doing the above upgrade. I'm not convinced this is always necessary (and would welcome comments one way or the other), but if you find you are having problems with Zaptel, try entering these commands from the command prompt:
(You may need to reboot at this point:)
shutdown -r now
(After the reboot:)
[code]modprobe wcfxo[/code] — Do this [b]only[/b] if you have Zaptel devices installed in your system!!!
(The Nerd Vittles site suggests rebooting again. Personally I think they overdo it with the reboots, but maybe better safe than sorry. Again I'd appreciate clarification from more knowledgeable folks:)
shutdown -r now
If anyone finds that the above instructions need tweaking, please share your comments either by editing this page, or adding a comment below. Until there are a few comments noting success, I'd advise folks that are not that familiar with Linux to hold off on the upgrade, so that you don't take the chance of breaking something you can't fix.
[b]Comment by WAudette on Rhino R4FXO[/b]
Added Monday 15 of January, 2007 03:20:00 UTC
If you are running a Rhino Zaptel PCI Card like the R4FXO these Lines need to be added before building Zaptel.[b]
Next edit the Makefile in this directory.
Search for the place to add instructions to build the Rhino in by hitting
Then type [code]tor2 <enter>[/code]
Then add [code]R4FXO[/code] in front of tor2.
Exit the program by hitting
Save, answer [code]Yes[/code] and [code]<enter>[/code] to keep the same name. [code]Yes[/code] to overwrite as well if it asks you.
Then continue w/ make