http://ijasnahamed.blogspot.kr/2017/04/setup-asterisk-13-with-freepbx-13-in.html
Launch CentOS 7 AWS Ec2 Instance
- Log in to your aws console
- Go to ec2 management page and click Launch Instance on Instance page
- In Choose AMI step, go to AWS MarketPlace tab and search CentOS 7 on search field. List of centos 7 ami's will be available.
- Select CentOS 7 (x86_64) ami which is free tier eligible.
- Select your instance type and click configure instance. Keep default values from Configure Instance to Add Tags steps
- In configure security group, create a security group which allow minimum ports open
- SSH : port 22
- HTTP : port 80
- Custom UDP Rule : 10000-20000 (if you are giving RTP ports 10000-20000)
- Custom UDP Rule : 5060 (ChanSIP port)
- Custom TCP Rule : 5060 (ChanSIP Port)
- Click Launch Instance. Select your key file and accept terms to launch instance.
Setup CentOS Server
- SSH into newly created CentOS server with username centos and your key file.
- Update all existing packages
- sudo yum update -y
- Now start http service(you can access your server via browser by going to your server ip address)
- sudo systemctl enable httpd.service
- sudo systemctl start httpd.service
- If you are using nano editor, please install it because its not inbuilt installed. If you use vi, skip this step
- yum install nano
Install Asterisk
Please execute below as root user.
- Please disable selinux to avoid strange behavior during installation
- Run ‘sestatus’ to check selinux state
- if enabled, please run below commands
- sed -i 's/\(^SELINUX=\).*/\SELINUX=disabled/' /etc/sysconfig/selinux
- sed -i 's/\(^SELINUX=\).*/\SELINUX=disabled/' /etc/selinux/config
- Reboot
- If disabled, run step 2
- Run below commands
- yum -y update
- yum -y groupinstall core base "Development Tools"
- Now install prerequisite packages
- yum -y install lynx mariadb-server mariadb php php-mysql php-mbstring tftp-server
- yum -y install httpd ncurses-devel sendmail sendmail-cf sox newt-devel libxml2-devel libtiff-devel
- yum -y install audiofile-devel gtk2-devel subversion kernel-devel git php-process crontabs cronie
- yum -y install cronie-anacron wget vim php-xml uuid-devel sqlite-devel net-tools gnutls-devel php-pear unixODBC mysql-connector-odbc
- yum -y install gcc gcc-c++ make openssl-devel libtermcap-devel perl curl curl-devel
- yum -y install libtool-ltdl libtool-ltdl-devel unixODBC-devel
- yum -y install bison doxygen mlocate tar nmap bzip2 mod_ssl php-mcrypt flex screen libxml2 libtiff gmime gmime-devel net-snmp-utils net-snmp-devel neon openssl gnutls-utils
- pear install Console_Getopt
- Check if firewall is running or not by executing systemctl status firewalld
- If you see this error ‘if it shows Unit Firewalld.service could not be found.’, install firewall by below commands
- yum install firewalld
- systemctl start firewalld (start firewall service)
- Open firewall port 80 and reload it
- firewall-cmd --zone=public --add-port=80/tcp --permanent
- firewall-cmd --reload
- Enable mariadb (freepbx use mariadb to log cdr reports)
- systemctl enable mariadb.service
- systemctl start mariadb
- Secure mysql installation by running mysql_secure_installation
- By default there won't be any password
- Don't set root password because freepbx will secure automatically
- Choose yes to remaining options. This will remove sample users and database, disable remote root logins and reload new rules so that mysql will take our changes immediately
- Reboot the server
- After rebooting, create a new user named asterisk
- adduser asterisk -M -c "Asterisk User"
- Execute below commands to install jansson
- cd /usr/src/
- git clone https://github.com/akheron/jansson.git
- cd /usr/src/jansson
- autoreconf -i
- ./configure
- make
- make install
- Now install pjproject by running below commands
- cd /usr/src
- wget http://www.pjsip.org/release/2.4/pjproject-2.4.tar.bz2
- tar -xjvf pjproject-2.4.tar.bz2
- rm -f pjproject-2.4.tar.bz2
- cd pjproject-2.4
- CFLAGS='-DPJ_HAS_IPV6=1' ./configure --prefix=/usr --enable-shared --disable-sound --disable-resample --disable-video --disable-opencore-amr --libdir=/usr/lib64
- make dep
- make
- make install
- Now install asterisk
- cd /usr/src
- wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
- tar xvfz asterisk-13-current.tar.gz
- cd asterisk-13.*
- cd ./contrib/scripts
- ./install_prereq install
- ./install_prereq install-unpackaged
- cd /usr/src/asterisk-13.*
- ./configure --libdir=/usr/lib64
- ./configure --with-pjproject --with-ssl --with-srtp
- contrib/scripts/get_mp3_source.sh
- make menuselect
- Now a screen will appear to select packages to install. Along with selected packages, please select below packages
- format_mp3(from add-ons tab)
- res_config_mysql, app_mysql, cdr_mysql (from Add-ons tab)
- res_odbc, func_odbc
- chan_pjsip (from Channel Driver tab)
- Press F12 to save this menu
- make
- make install
- make config
- ldconfig
- Start asterisk by systemctl start asterisk
- To know asterisk status, run systemctl status asterisk
- chkconfig asterisk off
- Now change asterisk directories to asterisk user
- chown asterisk. /var/run/asterisk
- chown -R asterisk. /etc/asterisk
- chown -R asterisk. /var/{lib,log,spool}/asterisk
- chown -R asterisk. /usr/lib/asterisk OR chown -R asterisk. /usr/lib64/asterisk
- chown -R asterisk. /var/www/
- To install freepbx, need to change some values to php and httpd
- sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php.ini
- sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/httpd/conf/httpd.conf
- sed -i 's/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf
- Now restart apache
- systemctl restart httpd.service
- Make asterisk database(if required)
- ASTERISK_DB_PW='pa2sw0rd'
- mysqladmin -u root create asterisk
- mysqladmin -u root create asteriskcdrdb
- mysql -u root -e "GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY '${ASTERISK_DB_PW}';"
- mysql -u root -e "GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY '${ASTERISK_DB_PW}';"
- mysql -u root -e "flush privileges;"
- Install freepbx
- cd /usr/src
- wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-13.0-latest.tgz
- tar xfz freepbx-13.0-latest.tgz
- rm -f freepbx-13.0-latest.tgz
- cd /usr/src/freepbx
- ./start_asterisk start
- ./install -n
- If this fails, reboot server and re-execute step 16.5 to 16.7
- Now install freepbx necessary packages
- fwconsole chown
- fwconsole ma installall
- fwconsole ma upgradeall
- fwconsole ma refreshsignatures
- fwconsole reload
- fwconsole restart
- Update firewall rules
- firewall-cmd --zone=public --add-port=5060/tcp --permanent
- firewall-cmd --zone=public --add-port=5060/udp --permanent
- firewall-cmd --reload
- Make freepbx to run on server startup
- Create a file freepbx.service in /etc/systemd/system and add below code to it and save
[Unit]
Description=FreePBX VoIP Server
After=mariadb.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/fwconsole start
ExecStop=/usr/sbin/fwconsole stop
[Install]
WantedBy=multi-user.target- systemctl enable freepbx.service
- systemctl status freepbx
Configuring FreePBX
- If your server external ip is 1.2.3.4, then go to http://1.2.3.4 in your browser. This will be your freepbx web panel
- On first time, you will be asked to set administrator username and password.
- On setting admin credentials, login to admin panel with your admin credentials