Last active
August 2, 2021 20:32
-
-
Save savelee/e2877fa44a0747344dde4d49c0e1039d to your computer and use it in GitHub Desktop.
Installing FreePBX15 with Asterisk 16 on Compute Engine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Create Compute | |
$ gcloud beta compute --project=dialogflow-ivr instances create "freepbx" --zone "us-central1-a" --machine-type=n1-standard-1 --subnet=default --network-tier=PREMIUM --maintenance-policy=MIGRATE --service-account=293782603063-compute@developer.gserviceaccount.com --scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/trace.append --image=centos-7-v20200420 --tags "http-server","https-server" --image-project=centos-cloud --boot-disk-size=40GB --boot-disk-type=pd-standard --boot-disk-device-name=instance-1 --no-shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring --reservation-affinity=any | |
## Edit the VM, add the following metadata label: | |
startup-script : sudo ufw ssh | |
## SSH into the machine | |
$ gcloud compute ssh <instancename> --project=projectname | |
## Disable SELINUX | |
$ sed -i 's/\(^SELINUX=\).*/\SELINUX=disabled/' /etc/sysconfig/selinux | |
$ sed -i 's/\(^SELINUX=\).*/\SELINUX=disabled/' /etc/selinux/config | |
$ sudo reboot; | |
## Install all the tools | |
$ sudo yum -y update | |
$ sudo yum -y groupinstall core base "Development Tools" | |
$ sudo yum -y install lynx mariadb-server mariadb php php-mysql php-mbstring tftp-server httpd ncurses-devel sendmail sendmail-cf sox newt-devel libxml2-devel libtiff-devel audiofile-devel gtk2-devel subversion kernel-devel git php-process crontabs cronie cronie-anacron wget vim php-xml uuid-devel sqlite-devel net-tools gnutls-devel php-pear unixODBC mysql-connector-odbc | |
$ sudo pear install Console_Getopt | |
## Firewall Config | |
$ sudo firewall-cmd --zone=public --add-port=80/tcp --permanent | |
$ sudo firewall-cmd --reload | |
## Upgrade PHP from 5.4 to 5.6 | |
$ sudo rpm -Uvh https://rpms.remirepo.net/enterprise/remi-release-7.rpm | |
$ sudo nano /etc/yum.repos.d/remi.repo | |
## change the enabled flag for the [remi] and [remi-php56] sections. | |
$ sudo yum -y upgrade php* | |
$ php -v | |
## Install Node JS and upgrade to latest version | |
$ curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash - | |
$ sudo yum install nodejs | |
$ sudo npm install -g n | |
$ sudo n stable | |
$ sudo ln -sf /usr/local/n/versions/node/12.16.2/bin/node /usr/bin/node | |
## MariaDB setup | |
$ sudo systemctl enable mariadb | |
$ sudo systemctl start mariadb | |
$ mysql_secure_installation | |
## Enable and start Apache web server | |
$ systemctl enable httpd | |
$ systemctl start httpd | |
## Install dependancies for Google Voice (optional) | |
$ cd /usr/src | |
$ sudo wget | |
https://src.fedoraproject.org/lookaside/pkgs/iksemel/iksemel-1.4.tar.gz/532e77181694f87ad5eb59435d11c1ca/iksemel-1.4.tar.gz | |
$ tar xf iksemel-*.tar.gz | |
$ rm -f iksemel-1.4.tar.gz | |
$ cd iksemel-* | |
$ ./configure | |
$ make | |
$ make install | |
## Download Asterisk 16 | |
$ sudo wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz | |
$ sudo wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz | |
$ sudo wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-current.tar.gz | |
$ sudo wget -O jansson.tar.gz https://github.com/akheron/jansson/archive/v2.7.tar.gz | |
$ sudo wget http://www.pjsip.org/release/2.4/pjproject-2.4.tar.bz2 | |
# Install DAHDI (only required if you use PSTN hardware, T1, E1, etc. | |
$ cd /usr/src | |
$ tar xvfz dahdi-linux-complete-current.tar.gz | |
$ tar xvfz libpri-current.tar.gz | |
$ rm -f dahdi-linux-complete-current.tar.gz libpri-current.tar.gz | |
$ cd dahdi-linux-complete-* | |
$ make all | |
$ make install | |
$ make config | |
$ cd /usr/src/libpri-* | |
$ make | |
$ make install | |
## Compile and install pjproject. | |
$ cd /usr/src | |
$ 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 | |
## Compile and install jansson | |
$ cd /usr/src | |
$ tar vxfz jansson.tar.gz | |
$ rm -f jansson.tar.gz | |
$ cd jansson-* | |
$ autoreconf -i | |
$ ./configure --libdir=/usr/lib64 | |
$ make | |
$ make install | |
## Install Asterisk 16 | |
$ sudo tar xvfz asterisk-16-current.tar.gz | |
$ cd asterisk-* | |
$ sudo contrib/scripts/install_prereq install | |
$ sudo ./configure --with-jansson-bundled --libdir=/usr/lib64 | |
$ sudo contrib/scripts/get_mp3_source.sh | |
$ sudo make menuselect | |
# make menuselect will display a window in the terminal, check format_mp3 to add mp3 playback and encoding. - save and exit | |
$ sudo make | |
$ sudo make install | |
$ sudo make config | |
$ sudo ldconfig | |
$ sudo chkconfig asterisk off | |
## Installing higher quality asterisk sound files. | |
$ sudo /var/lib/asterisk/sounds | |
$ sudo wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-wav-current.tar.gz | |
$ sudo wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-wav-current.tar.gz | |
$ sudo tar xvf asterisk-core-sounds-en-wav-current.tar.gz | |
$ sudo rm -f asterisk-core-sounds-en-wav-current.tar.gz | |
$ tar xfz asterisk-extra-sounds-en-wav-current.tar.gz | |
$ rm -f asterisk-extra-sounds-en-wav-current.tar.gz | |
$ sudo wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-g722-current.tar.gz | |
$ sudo wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-g722-current.tar.gz$ | |
$ sudo tar xfz asterisk-extra-sounds-en-g722-current.tar.gz | |
$ rm -f asterisk-extra-sounds-en-g722-current.tar.gz | |
$ sudo tar xfz asterisk-core-sounds-en-g722-current.tar.gz | |
$ rm -f asterisk-core-sounds-en-g722-current.tar.gz | |
## setting asterisk user permissions. I had to add an asterisk user at this point. | |
$ sudo useradd asterisk | |
$ sudo chown asterisk. /var/run/asterisk | |
$ sudo chown -R asterisk. /etc/asterisk | |
$ sudo chown -R asterisk. /var/{lib,log,spool}/asterisk | |
$ sudo chown -R asterisk. /usr/lib64/asterisk | |
$ sudo chown -R asterisk. /var/www/ | |
## Apache modifications. | |
$ sudo sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php.ini | |
$ sudo sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/httpd/conf/httpd.conf | |
$ sudo sed -i 's/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf | |
$ sudo systemctl restart httpd.service | |
## Install FreePBX 15 | |
# sudo nano /etc/sysconfig/asterisk | |
# comment out: | |
#AST_USER="asterisk" #AST_USER="asterisk" | |
$ cd /usr/src | |
$ sudo wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-15.0-latest.tgz | |
$ tar xfz freepbx-15.0-latest.tgz | |
$ rm -f freepbx-15.0-latest.tgz | |
$ cd freepbx | |
$ sudo ./start_asterisk start | |
$ sudo ./install -n --dbpass $password-maria-db | |
# Centos 7 systemd config, to autostart freePBX on boot. | |
# Create a file named freepbx.service in /etc/systemd/system containing the following text: | |
[Unit] | |
Description=FreePBX VoIP Server | |
After=mariadb.service | |
[Service] | |
Type=oneshot | |
RemainAfterExit=yes | |
ExecStart=/usr/sbin/fwconsole start -q | |
ExecStop=/usr/sbin/fwconsole stop -q | |
[Install] | |
WantedBy=multi-user.target | |
https://reiners.io/installing-freepbx-on-centos-on-google-cloud-platform/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment