This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
voice:pbx:freepbx_scratch [2012/06/04 11:21] gcooper |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Build a PBX from Scratch Using CentOS 6, Asterisk and FreePBX ====== | ||
- | http:// | ||
- | |||
- | ===== Minimal CentOS 6 Install ===== | ||
- | |||
- | Do a [[computing: | ||
- | |||
- | After the reboot: | ||
- | |||
- | < | ||
- | yum update -y | ||
- | </ | ||
- | |||
- | then reboot again. | ||
- | |||
- | ===== XenServer Tools ===== | ||
- | |||
- | If installing on XenServer (skip otherwise): | ||
- | |||
- | - Mount the XenServer Tools virtual CD into the VM | ||
- | - < | ||
- | - < | ||
- | - < | ||
- | |||
- | ===== Install Prerequisites ===== | ||
- | |||
- | < | ||
- | yum -y groupinstall base core | ||
- | |||
- | yum -y install gcc gcc-c++ wget bison mysql-devel mysql-server php php-mysql php-pear php-pear-DB php-mbstring php-process nano tftp-server httpd make ncurses-devel libtermcap-devel sendmail sendmail-cf caching-nameserver sox newt-devel libxml2-devel libtiff-devel php-gd audiofile-devel gtk2-devel subversion nano kernel-devel | ||
- | |||
- | yum clean all | ||
- | </ | ||
- | |||
- | ===== Firewall ===== | ||
- | |||
- | Disable the built-in firewall for now. We assume your PBX is in a protected, private environment. | ||
- | |||
- | :!: See Security section below. | ||
- | |||
- | < | ||
- | service iptables stop | ||
- | chkconfig iptables off | ||
- | service ip6tables stop | ||
- | chkconfig ip6tables off | ||
- | </ | ||
- | |||
- | ===== selinux ===== | ||
- | |||
- | Disable selinux: | ||
- | |||
- | < | ||
- | vim / | ||
- | |||
- | SELINUX=disabled | ||
- | </ | ||
- | |||
- | < | ||
- | setenforce 0 | ||
- | </ | ||
- | |||
- | ===== Time Zone ===== | ||
- | |||
- | http:// | ||
- | |||
- | < | ||
- | ln -sf / | ||
- | </ | ||
- | |||
- | ===== PHP Settings ===== | ||
- | |||
- | ==== Time Zone ==== | ||
- | |||
- | < | ||
- | vim -c 946 / | ||
- | </ | ||
- | |||
- | Uncomment and set PHP timezone: | ||
- | |||
- | < | ||
- | date.timezone = America/ | ||
- | </ | ||
- | |||
- | ==== Upload File Size ==== | ||
- | |||
- | < | ||
- | vim -c 878 / | ||
- | |||
- | upload_max_filesize = 20M | ||
- | </ | ||
- | |||
- | ===== Install PBX Software ===== | ||
- | |||
- | ==== Asterisk v1.8 ==== | ||
- | |||
- | < | ||
- | wget http:// | ||
- | tar zxvf asterisk-1.8-current.tar.gz | ||
- | cd / | ||
- | make clean | ||
- | ./configure && make menuselect | ||
- | </ | ||
- | |||
- | Select all addons. | ||
- | |||
- | :!: If upgrading Asterisk on an already running FreePBX system do NOT run make samples. | ||
- | |||
- | < | ||
- | make && make install && make samples | ||
- | </ | ||
- | |||
- | Create an ' | ||
- | |||
- | < | ||
- | useradd -c " | ||
- | </ | ||
- | |||
- | The following directory may already exist but just to make sure: | ||
- | |||
- | < | ||
- | mkdir / | ||
- | </ | ||
- | |||
- | Set ownership of various folders: | ||
- | |||
- | < | ||
- | chown -R asterisk / | ||
- | chown -R asterisk / | ||
- | chown -R asterisk / | ||
- | chown -R asterisk / | ||
- | </ | ||
- | |||
- | Adjust the manager interface username and password: | ||
- | |||
- | < | ||
- | vim / | ||
- | </ | ||
- | |||
- | Add a stanza like: | ||
- | |||
- | < | ||
- | [admin] | ||
- | secret = your-manager-password | ||
- | deny=0.0.0.0/ | ||
- | permit=127.0.0.1/ | ||
- | read = system, | ||
- | write = system, | ||
- | </ | ||
- | |||
- | ==== Music on Hold ==== | ||
- | |||
- | Here we create a symbolic link so that both FreePBX and Asterisk will find and store MOH files in the same place: | ||
- | |||
- | < | ||
- | ln -s / | ||
- | </ | ||
- | |||
- | Asterisk and FreePBX now only use .wav files for MOH so install mpg123 for converting uploaded mp3's to wav's: | ||
- | |||
- | < | ||
- | cd /usr/src | ||
- | wget http:// | ||
- | tar -xjvf mpg123-1.13.4.tar.bz2 | ||
- | |||
- | cd mpg123-1.13.4 | ||
- | ./configure && make && make install | ||
- | |||
- | ln -s / | ||
- | </ | ||
- | |||
- | ==== Web Server ==== | ||
- | |||
- | Here we set the web server to run as the user ' | ||
- | |||
- | < | ||
- | sed -i " | ||
- | sed -i " | ||
- | </ | ||
- | |||
- | ==== MySQL Configuration ==== | ||
- | |||
- | === Start MySQL === | ||
- | |||
- | < | ||
- | service mysqld start | ||
- | </ | ||
- | |||
- | === Create Databases and Tables === | ||
- | |||
- | < | ||
- | cd / | ||
- | mysqladmin create asterisk | ||
- | mysqladmin create asteriskcdrdb | ||
- | mysql asterisk < SQL/ | ||
- | mysql asteriskcdrdb < SQL/ | ||
- | </ | ||
- | |||
- | === Configure MySQL Security === | ||
- | |||
- | < | ||
- | mysql | ||
- | </ | ||
- | |||
- | Run these MySQL commands and adjust for your own password: | ||
- | |||
- | < | ||
- | GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY ' | ||
- | |||
- | GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY ' | ||
- | |||
- | flush privileges; | ||
- | |||
- | exit | ||
- | </ | ||
- | |||
- | Finally, we set the MySQL root password. | ||
- | |||
- | < | ||
- | mysqladmin -u root password ' | ||
- | </ | ||
- | |||
- | ==== Install FreePBX ==== | ||
- | |||
- | Get the latest released version. | ||
- | |||
- | < | ||
- | cd /usr/src | ||
- | wget http:// | ||
- | tar zxvf freepbx-2.10.0.tar.gz | ||
- | </ | ||
- | |||
- | :!: MySQL should still be running... | ||
- | |||
- | Start asterisk. | ||
- | |||
- | < | ||
- | / | ||
- | |||
- | cd / | ||
- | ./ | ||
- | </ | ||
- | |||
- | You will be asked various questions which will be used to populate / | ||
- | |||
- | Use the defaults, mostly, but change: | ||
- | |||
- | ^Variable^Value^ | ||
- | |AMPMGRUSER|admin| | ||
- | |AMPMGRPASS|password you set when editing manager.conf above| | ||
- | |AMPDBPASS|password you chose when configuring MySQL security above| | ||
- | |AMPWEBADDRESS|the IP address of your PBX| | ||
- | |||
- | Now we delete a few configuration files that may interfere with FreePBX: | ||
- | |||
- | < | ||
- | rm -f / | ||
- | </ | ||
- | |||
- | ==== MySQL CDR Configuration ==== | ||
- | |||
- | < | ||
- | vim / | ||
- | |||
- | loguniqueid=yes | ||
- | </ | ||
- | |||
- | ==== Log Rotation ==== | ||
- | |||
- | < | ||
- | cat << EOF >> / | ||
- | / | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | / | ||
- | | ||
- | } | ||
- | EOF | ||
- | |||
- | kill -HUP $(pidof rsyslogd) | ||
- | </ | ||
- | |||
- | ==== Services Startup ==== | ||
- | |||
- | Enable Apache, MySQL and FreePBX to autostart on boot: | ||
- | |||
- | < | ||
- | chkconfig httpd on | ||
- | chkconfig mysqld on | ||
- | echo / | ||
- | </ | ||
- | |||
- | :!: Reboot now! | ||
- | |||
- | ===== Using FreePBX ===== | ||
- | |||
- | :!: Before using FreePBX, you have to visit the configuration page at: http:// | ||
- | |||
- | :!: Click "Apply Configuration Changes" | ||
- | |||
- | :!: Reboot again | ||
- | |||
- | ==== Defailt Credentials ==== | ||
- | |||
- | ^Function^Username^Password^Comment^ | ||
- | |FreePBX|admin|admin| | | ||
- | |Voicemail & Recordings (ARI)|< | ||
- | |||
- | ==== Configuration ==== | ||
- | |||
- | The FreePBX administration console: http:// | ||
- | |||
- | === Enable ARI Administration === | ||
- | |||
- | //FreePBX -> Settings -> Advanced System Setup ->// | ||
- | |||
- | * User Portal Admin Username -> your-ari-admin-username | ||
- | * User Portal Admin Password -> your-ari-admin-password | ||
- | |||
- | Save each change and click Apply Configuration. | ||
- | |||
- | :!: See [[voice: | ||
- | |||
- | ===== Security ===== | ||
- | |||
- | ==== Firewall ==== | ||
- | |||
- | Pick one of these three firewall options. | ||
- | |||
- | === iptables === | ||
- | |||
- | < | ||
- | system-config-firewall-tui | ||
- | </ | ||
- | |||
- | The following ports need to be opened: | ||
- | |||
- | ^Protocol^Ports^Description^ | ||
- | |TCP|80|HTTP| | ||
- | |TCP|443|HTTPS| | ||
- | |TCP|4445|Flash Operator Panel| | ||
- | |UDP|5060-5061|SIP| | ||
- | |UDP|10000-20000|RTP| | ||
- | |UDP|4569|IAX| | ||
- | |||
- | === Arno's Firewall === | ||
- | |||
- | [[networking: | ||
- | |||
- | === Fail2Ban === | ||
- | |||
- | / | ||
- | |||
- | ===== Troubleshooting ===== | ||
- | |||
- | ==== Asterisk Manager Interface ==== | ||
- | |||
- | Verify that the username and password in / | ||
- | |||
- | http:// | ||
- | |||
- | ==== Pear DB ==== | ||
- | |||
- | If you see an error during FreePBX installation like: | ||
- | |||
- | < | ||
- | Checking for PEAR DB..FAILED | ||
- | </ | ||
- | |||
- | try: | ||
- | |||
- | < | ||
- | pear install DB | ||
- | </ | ||
- | |||
- | then re-run: | ||
- | |||
- | < | ||
- | ./ | ||
- | </ | ||
- | |||
- | ==== Remote Extensions ==== | ||
- | |||
- | :!: If you enable remote access to your PBX, **secure it!** | ||
- | |||
- | :!: NAT is a real hurdle for SIP. The best way to deal with NAT issues is to not use NAT if at all possible. | ||
- | |||
- | === IAX Protocol === | ||
- | |||
- | :!: Using phones with IAX protocol support is a good alternative if the PBX is behind NAT. | ||
- | |||
- | :!: IAX protocol is pretty much Asterisk-specific. | ||
- | |||
- | If your PBX is behind NAT, forward the single UDP port 4569 from your NAT firewall in to the PBX. | ||
- | |||
- | === SIP Protocol === | ||
- | |||
- | http:// | ||
- | |||
- | If your PBX is behind NAT and you'd still like to try getting remote SIP extensions to work: | ||
- | |||
- | < | ||
- | vim / | ||
- | |||
- | localnet=192.168.1.0/ | ||
- | externhost=your.fqdn.hostname | ||
- | fromdomain=your.fqdn.domain.name | ||
- | nat=yes | ||
- | qualify=yes | ||
- | externrefresh=10 | ||
- | canreinvite=no | ||
- | |||
- | asterisk -rx reload | ||
- | </ | ||
- | |||
- | ==== PHP Memory Limit ==== | ||
- | |||
- | This should be the default: | ||
- | |||
- | < | ||
- | vim -c 457 / | ||
- | </ | ||
- | |||
- | < | ||
- | memory_limit = 128M | ||
- | </ | ||
- | |||
- | ==== Re-Install Just FreePBX ==== | ||
- | |||
- | < | ||
- | amportal stop | ||
- | |||
- | rm -f / | ||
- | |||
- | / | ||
- | |||
- | cd / | ||
- | ./ | ||
- | </ | ||
- | |||
- | Visit the configuration page at: http:// | ||
- | |||
- | Click “Apply Settings” | ||
- | |||
- | Reboot |