FreePBX slow “Apply Configuration”

Some may have problems loading FreePBX that takes a few minutes esp with larger number of extensions.
This is actually addressed in this article in FreePBX.org http://www.freepbx.org/trac/ticket/4435 but if you just want to fix it and don’t read all the stories there, read on.
NOTE: This article is ala-debian, so please do your due diligence for non-debians.
IMPORTANT!
Make sure you do all updates of modules to the latest minor version (upgrade all) before doing this below In future when you upgrade the CORE and FRAMEWORK, this below patch will be overwritten, so you need to do this again.
For clusters setups, please note if you already replicate certain directories of Asterisk/WWW, this may only needed to be done on the Master (or active) node.
NOTE: THIS FIX IS PORTED TO VERSION 2.9, SO YOU DO NOT NEED TO DO THIS ON 2.9 ONWARDS (not available yet of course)
Here’s the step by step:
Patch php-asmanager.php
cd /var/www/html/admin/common/
wget http://210.5.42.12/downloads/asterisk/misc/freepbx-fix/astdb_cache.diff
cp php-asmanager.php ./php-asmanager.php-original
patch php-asmanager.php astdb_cache.diff
chown asterisk:asterisk php-asmanager.php
Patch retrieve_conf
cd /var/lib/asterisk/bin
wget http://210.5.42.12/downloads/asterisk/misc/freepbx-fix/retrieve_conf.diff
cp retrieve_conf ./retrieve_conf-original
patch retrieve_conf retrieve_conf.diff
chown asterisk:asterisk retrieve_conf
cp /etc/php5/apache2/php.ini /etc/php5/apache2/php.ini-orig
sed -i “s/upload_max_filesize = 20M/upload_max_filesize = 120M/” /etc/php5/apache2/php.ini
sed -i “s/upload_max_filesize = 2M/upload_max_filesize = 120M/” /etc/php5/apache2/php.ini
sed -i “s/magic_quotes_gpc = On/magic_quotes_gpc = Off/” /etc/php5/apache2/php.ini
sed -i “s/memory_limit = 16M/memory_limit = 100M/” /etc/php5/apache2/php.ini
sed -i “s/memory_limit = 32M/memory_limit = 100M/” /etc/php5/apache2/php.ini
RESTART apache.
/etc/init.d/apache2 restart
Now, try modifying something and do your apply.