Install freePBX

/usr/sbin/safe_asterisk
cd /usr/src/freepbx-2.3.x
./install_amp
Checking for PEAR DB..OK
Checking for PEAR Console::Getopt..OK
Checking for libasteriskperl (perl bindings for asterisk)...Checking user..OK
Checking for /etc/amportal.conf../etc/amportal.conf does not exist, copying default
Creating new /etc/amportal.conf
Enter your USERNAME to connect to the 'asterisk' database: [asteriskuser]
Enter your PASSWORD to connect to the 'asterisk' database: [amp109]
Enter the hostname of the 'asterisk' database: [localhost]
Enter a USERNAME to connect to the Asterisk Manager interface: [admin]
Enter a PASSWORD to connect to the Asterisk Manager interface:[amp111]
Enter the path to use for your AMP web root:[/var/www/html]
Enter the path to use for your FOP web root:[/var/www/html/panel]
Created /var/www/html/panel
Enter the path to your Apache cgi-bin:[/var/www/cgi-bin]
Enter the IP ADDRESS or hostname used to access the AMP web-admin:[xx.xx.xx.xx] The IP Address of your Asterisk Machine
**NOTE: Leave this IP blank if you intend to access Flash Operator Panel from the Internet Enter a PASSWORD to perform call transfers with the Flash Operator Panel: [passw0rd]
Use simple Extensions [extensions] admin or separate Devices and Users [deviceanduser]? extensions
Enter directory in which to store AMP executable scripts: [/var/lib/asterisk/bin]
Created /var/lib/asterisk/bin
Enter directory in which to store super-user scripts: [/usr/sbin]
/etc/amportal.conf writtenOK
Reading /etc/amportal.conf..OK
Checking for /etc/asterisk/asterisk.conf../etc/asterisk/asterisk.conf does not exist, copying default
OK
.
.
.
OK
Please Reload Asterisk by visiting
http://XXX.XXX.XXX.XX/admin

If you get any warnings or errors in the last part of the output, they're usually not traumatic, but please use the IRC Support tool to report a bug to the developers.

amportal
Usage: amportal start|stop|restart|start_fop|stop_fop|restart_fop|kill|chownspan style="background-color: #E9ECEF; background-position: 0% 0%">

start: Starts Asterisk and Flash Operator Panel server if enabled
stop: Gracefully stops Asterisk and the FOP server
restart: Stop and Starts
start_fop: Starts FOP server and Asterisk if not running
stop_fop: Stops FOP serverg
restart_fop: Stops FOP server and Starts it and Asterisk if not running
kill: Kills Asterisk and the FOP server
chown: Sets appropriate permissions on files
 

Set FOP to run on startup
nano +52 /etc/amportal.conf
FOPRUN=true


The amportal script is the recommended way to stop and start asterisk:
/usr/local/sbin/amportal stop
/usr/local/sbin/amportal start

Automatic start-up
echo /usr/local/sbin/amportal start >> /etc/rc.local

For some reason it has become necessary to change amportal.conf access restrictions around about FreePBX v2.2.x
chmod 775 /etc/amportal.conf

Edit /etc/asterisk/cdr_mysql.conf and add logunieqid=yes nano /etc/asterisk/cdr_mysql.conf
loguniqueid=yes