How to upgrade Asterisk
Note: 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.
Note 2: 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.
Note 3: 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 yum -y install kernel-devel kernel 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 in the same branch as the version shown below - if so, you may want to try the newer version:
http://downloads.asterisk.org/pub/asterisk/releases/
http://downloads.asterisk.org/pub/zaptel/releases/ (if using dahdi rather than zaptel: http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/releases/)
http://downloads.asterisk.org/pub/libpri/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 in the same branch 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):
cd /usr/src wget http://downloads.asterisk.org/pub/asterisk/releases/asterisk-1.2.32.tar.gz tar -xzvf ./asterisk-1.2.32.tar.gz wget http://downloads.asterisk.org/pub/zaptel/releases/zaptel-1.2.27.tar.gz tar -xzvf ./zaptel-1.2.27.tar.gz wget http://downloads.asterisk.org/pub/libpri/releases/libpri-1.2.8.tar.gz tar -xzvf ./libpri-1.2.8.tar.gz wget http://downloads.asterisk.org/pub/asterisk/releases/asterisk-addons-1.2.9.tar.gz tar -xzvf ./asterisk-addons-1.2.9.tar.gz wget http://downloads.asterisk.org/pub/asterisk/releases/asterisk-sounds-1.2.1.tar.gz tar -xzvf asterisk-sounds-1.2.1.tar.gz
cd /usr/lib/asterisk/ mv modules ./old-modules-backup
Now compile and install (note the directory names will be different if you installed different versions):
Note: If you are running a Rhino Zaptel PCI Card like the R4FXO, please see the comment by WAudette at the bottom of this page before proceeding with the next step.
Note: If you are using the Open Source Line Echo Canceller (OSLEC) then you will want to patch Zaptel before running make. See this page and look for the section heading "HowTo - Run OSLEC with Asterisk/Zaptel."
cd /usr/src/zaptel-1.2.27 make clean make make install
sed -i s/rw_lock/rwlock/ /usr/src/kernels/*/include/linux/spinlock.h
sed -i s/rw_lock/rwlock/ /usr/include/linux/spinlock.h
cd ../libpri-1.2.8 make clean make make install cd ../asterisk-1.2.32 make clean make make install cd ../asterisk-addons-1.2.9 make clean make make install cd ../asterisk-sounds-1.2.1 make install
(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:
app_flite.so
app_managerredirect.so
app_mwanalyze.so
app_nv_backgrounddetect.so
app_nv_faxdetect.so
app_rxfax.so
app_txfax.so
cdr_odbc.so
cdr_pgsqI.so
chan_h323.so
format_ogg_vorbis.so
res_config_odbc.so
res_odbc.so
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:
tail /var/log/asterisk/full
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 shutdown -r now), 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:
amportal stop rebuild_zaptel
shutdown -r now
modprobe wcfxo — Do this only if you have Zaptel devices installed in your system!!!amportal stop genzaptelconf
shutdown -r now
Comment by WAudette on Rhino R4FXO
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]
cd /usr/src/zaptel-1.2.27 wget ftp://ftp.rhinoequipment.com/R4FXO/Drivers/latest/r4fxo.c wget ftp://ftp.rhinoequipment.com/R4FXO/Drivers/latest/r4fxo.h
Next edit the Makefile in this directory.
nano Makefile
<CTRL-W>
Then type tor2 <enter>
Then add R4FXO in front of tor2.
Exit the program by hitting
<CTRL-X>
Save, answer Yes and <enter> to keep the same name. Yes to overwrite as well if it asks you.
Then continue w/ make