How to Install FreePBX on Ubuntu Linux

|

|

This tutorial guides through the process of installing FreePBX, an open-source web application to manage Asterisk platform, on Ubuntu. The steps include installing Asterisk PBX for managing the system, Apache2 HTTP Server, MariaDB Database Server, PHP 7.2 and related modules to aid FreePBX functioning. It also instructs on installing Node.js. After setting up all these…

This brief tutorial shows students and new users how to install FreePBX on Ubuntu 18.04 | 16.04.

FreePBX is an open-source, web-based application that can manage the Asterisk (PBX) platform. It provides a simple-to-use interface to manage complicated phone trees and other features, making it an ideal solution for businesses and organizations that want to manage their phone systems.

Installing FreePBX on Ubuntu Linux provides a reliable, cost-effective, and customizable solution for managing your PBX system.

Additionally, Ubuntu Linux is a free and open-source operating system that provides high security and flexibility, making it an excellent choice for running FreePBX.

To get started with managing FreePBX, follow the steps below:

Install Asterisk PBX

Since you will manage Asterisk, your first task will be installing it. The good thing is we’ve shown our users how to install Asterisk on Ubuntu.

Below is a tutorial that shows you how to install Asterisk on Ubuntu.

How to install Asterisk PBX on Ubuntu Linux

After installing the Asterisk above, continue below to install and configure FreePBX.

Apache HTTP Server

Apache2 HTTP Server is the most popular web server, so install it since FreePBX needs it.

To install Apache2 HTTP on the Ubuntu server, run the commands below.

sudo apt update
sudo apt install apache2

After installing Apache2, the commands below can stop, start, and enable the Apache2 service to always start up with the server boots.

sudo systemctl stop apache2.service
sudo systemctl start apache2.service
sudo systemctl enable apache2.service

To determine if the Apache2 HTTP server is installed, simply open your web browser and type in the server’s IP or hostname.

When you see a page similar to the one below, Apache2 is installed and working.

http://localhost

After that, run the commands below to remove the Apache2 default index.html file.

sudo rm /var/www/html/index.html 

Install MariaDB Database Server

FreePBX also needs a database server to store its content. And MariaDB database server is a great place to start when looking at open-source database servers to use with FreePBX.

To install MariaDB, run the commands below.

sudo apt install mariadb-server mariadb-client

After installing MariaDB, the commands below can stop, start, and enable the service to start when the server boots.

Run these on Ubuntu

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

After that, run the commands below to secure the MariaDB server by creating a root password and disallowing remote root access.

sudo mysql_secure_installation

When prompted, answer the questions below by following the guide.

  • Enter current password for root (enter for none): Just press the Enter
  • Set root password? [Y/n]: Y
  • New password: Enter password
  • Re-enter new password: Repeat password
  • Remove anonymous users? [Y/n]: Y
  • Disallow root login remotely? [Y/n]: Y
  • Remove test database and access to it? [Y/n]:  Y
  • Reload privilege tables now? [Y/n]:  Y

Restart MariaDB server

To test if MariaDB is installed, type the commands below to log into the MariaDB server

sudo mysql -u root -p

To test if MariaDB is installed and working, run the commands below:

sudo systemctl status mariadb

That should display MariaDB’s service status.

● mariadb.service - MariaDB 10.1.44 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-04-08 17:08:17 CDT; 1min 54s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 22363 (mysqld)

By default, MariaDB is configured to use the UNIX auth_socket plugin on Ubuntu. You’ll want to run the SQL commands below for the root user to use mysql_native_password.

You’ll need a MariaDB root account to set up FreePBX later.

Run the commands below to log on to MariaDB. When prompted for a password, type the root password you created above.

sudo mysql -u root -p

Switch to the MySQL database.

use mysql;

Then, update the root account to use mysql_native_password.

UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root';

Finally, save your changes and exit.

FLUSH PRIVILEGES;
EXIT;

Install PHP 7.2 and Related Modules

PHP 7.2 may not be available in Ubuntu default repositories. To install it, you must get it from third-party repositories.

Run the commands below to add the below third-party repository to upgrade to PHP 7.2

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php

Then update and upgrade to PHP 7.2

sudo apt update

Next, run the commands below to install PHP 7.2 and related modules.

sudo apt install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-gmp php7.2-curl php7.2-intl php7.2-mbstring php7.2-xmlrpc php7.2-mysql php7.2-gd php7.2-imap php7.2-ldap php-cas php7.2-bcmath php7.2-xml php7.2-cli php7.2-zip php7.2-sqlite3

After installing PHP 7.2, run the commands below to open the PHP default config file for Apache2.

sudo nano /etc/php/7.2/apache2/php.ini

Then, save the changes on the following lines below in the file. The value below is an ideal setting to apply in your environment.

file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 360
max_input_vars = 1500
date.timezone = America/Chicago

After making the change above, please save the file and close it.

To test PHP 7.2 settings with Apache2, create a phpinfo.php file in the Apache2 root directory by running the commands below

sudo nano /var/www/html/phpinfo.php

Then, type the content below and save the file.

<?php phpinfo( ); ?>

Save the file. Then browse to your server hostname followed by /phpinfo.php

http://localhost/phpinfo.php

You should see the PHP default test page.

Install Nodejs

After installing the server above, run the commands below to add Nodejs 10 repository to Ubuntu.

sudo apt update
sudo apt install curl dirmngr apt-transport-https lsb-release ca-certificates
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash

Then, run the commands below to install Nodejs.

sudo apt-get install gcc g++ make
sudo apt install nodejs

Install FreePBX

At this point, you should have everything ready for FreePBX. To download and install FreePBX, run the commands below:

sudo apt install wget
cd /tmp
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-15.0-latest.tgz
tar xfz freepbx-15.0-latest.tgz

Finally, run the commands below to install.

cd freepbx
sudo ./start_asterisk start
sudo ./install -n --dbuser root --dbpass type_root_password_here

If you get an error,

Error!
Unable to read /etc/asterisk/asterisk.conf or it was missing a directories section

run the commands below to resolve:

sudo cp /etc/asterisk/asterisk.conf.old /etc/asterisk/asterisk.conf

If you also get an error:

‘asterisk’ user…bash: line 0: cd: /home/asterisk/: No such file or directory

Run the commands below to resolve:

sudo mkhomedir_helper asterisk

When you have resolved all the errors above, try the installation again.

After installing, you should get a similar message as shown below:

Updating Hooks…Done
Done installing all modules
Taking too long? Customize the chown command, See http://wiki.freepbx.org/display/FOP/FreePBX+Chown+Conf
Setting Permissions…
Setting base permissions…Done
Setting specific permissions…
11864 [============================]
Finished setting permissions
Taking too long? Customize the chown command, See http://wiki.freepbx.org/display/FOP/FreePBX+Chown+Conf
Setting Permissions…
Setting base permissions…Done
Setting specific permissions…
11864 [============================]
Finished setting permissions
Generating default configurations…
Finished generating default configurations
You have successfully installed FreePBX

After installing, restart Apache2.

sudo a2enmod rewrite
sudo usermod -aG www-data asterisk
sudo systemctl restart apache2

Now, go and access the FreePBX portal.

http://localhost

Setup, login, and start building your PBX

That’s it!

Conclusion:

This post showed you how to install Asterisk and FreePBX to create your PBX systems. If you find any error above, please use the comment form below to report.

Thanks,

Like this:



45 responses to “How to Install FreePBX on Ubuntu Linux”

  1. tl Avatar
    tl

    sudo ./install -n –dbuser root –dbpass type_root_password_here

    PHP Fatal error: Uncaught Error: Call to undefined function FreePBX\Install\simplexml_load_file() in /tmp/freepbx/install:19

    HEEELP!!! )))

    1. Tayo Avatar
      Tayo

      You probably have multiple versions of php installed. check in /etc/php. If you have 7.2 and 7.4, you either run sudo apt install php7.4-xml or
      1. apt-get purge php7.*
      2. apt-get install -y php7.2
      3. apt-get install -y php7.2-xml

      the latter is preferred, i discovered php7.4 caused an error during the freepbx installation.

  2. NQ4T Avatar
    NQ4T

    cd to /etc/php and see which versions of PHP are installed. In my case, I had 7.2 and 7.4 apparently.

    sudo apt install php7.x-xml – where 7.x are the versions listed in /etc/php. You should find that the XML extension for one of the versions wasn’t installed. This should fix your problem.

  3. Kevin Avatar
    Kevin

    Hi, i have this problem “The command “/usr/sbin/fwconsole chown” failed.” after i wrote sudo ./install -n –dbuser root –dbpass (pass)

    Can anyone help me?

    Thanks a lot

    1. Olutayo Oyawale Avatar
      Olutayo Oyawale

      Do the following:
      1. apt-get purge php7.*
      2. apt-get install -y php7.2
      3. apt-get install -y php7.2-xml
      4. apt-get install -y php7.2-mysql
      5. sudo ./install -n –-dbuser root –-dbpass (pass)

      1. Ethan Avatar
        Ethan

        It works! Thanks

      2. Leendert-Jan Avatar
        Leendert-Jan

        Worked for me

      3. Meli Imelda Avatar
        Meli Imelda

        Thank you, I was facing a similar issue and doing this helped solve the problem

  4. Khuyen Hoang Avatar
    Khuyen Hoang

    I have an issue when start asterisk
    sudo ./start_asterisk start
    ./start_asterisk: line 45: /usr/sbin/safe_asterisk: No such file or directory
    Asterisk Started

    sudo ./install -n –dbuser root –dbpass password
    Error!
    Error communicating with Asterisk. Ensure that Asterisk is properly installed and running as the asterisk user
    Asterisk does not appear to be running
    Try starting Asterisk with the ‘./start_asterisk start’ command in this directory

    Could you please help

    1. Christina Avatar
      Christina

      Same issue for me. Would really like some help with this please.

  5. Antonino Avatar
    Antonino

    Hi, i’ve followed the procedures but http://localhost/admin/config.php is a white page

    1. Richard Troiano Avatar
      Richard Troiano

      I am getting the same thing, no errors during the entire process other than the ones outlined above, and by using the procedures I was able to get past the point where I was getting hung up previously, but when i go to http://localhost/ i get auto-redirected to http://localhost/admin/config.php, which is a blank (white with no text) website. I am running Ubuntu 20.04.

  6. Herbeth Avatar
    Herbeth

    Hi, i’ve followed the procedures but http://localhost/admin/config.php is a white page with HTTP ERROR 500

    1. Michael Schalck Avatar
      Michael Schalck

      Same for me…

    2. León Avatar
      León

      Hello mates, I have been investigating about that error (because I have it too) and I found some interesting information in this link:
      https://community.freepbx.org/t/yet-another-error-500-on-fresh-install/16731/11
      Maybe something could work.

      Please if someone tries it, tell us how to solve that error.

    3. León Avatar
      León

      Also, in my investigation i got an answer that maybe the time zone hast to be changed

    4. Jason Avatar
      Jason

      If you are on Ubuntu 20.04. installing php 7.4 worked for me. I used:

      sudo apt install php

      sudo sed -i ‘s/\(^upload_max_filesize = \).*/\120M/’ /etc/php/7.4/apache2/php.ini
      sudo sed -i ‘s/\(^upload_max_filesize = \).*/\120M/’ /etc/php/7.4/cli/php.ini

      sudo a2enmod rewrite
      sudo systemctl restart apache2

    5. gpc Avatar
      gpc

      i meet the same problem with,Did you solve it?

  7. Mike Avatar
    Mike

    Everything worked but http://localhost/admin/config.php is blank. Can anyone help? Thx

    1. Vikas Gupta Avatar
      Vikas Gupta

      same for me, help us
      Thanks

  8. Alex Avatar
    Alex

    +1

  9. Noah Amolo Avatar
    Noah Amolo

    For me, the error 500 looks like it is caused by a permissions issue. I have checke the file called error.log located in /var/log/apache2/ and it says PHP Warning: include_once(/etc/freepbx.conf): failed to open stream: Permission denied in /var/www/html/admin/config.php on line 126

    Still researching on a solution

    1. dddn37 Avatar
      dddn37

      sudo chmod 664 /etc/freepbx.conf

  10. Milan Novakovic Avatar
    Milan Novakovic

    sudo ufw allow proto tcp from any to any port 80,443

  11. Jim Avatar
    Jim

    sudo add-apt-repository ppa:ondrej/php

    Not working, have you an alternative?

  12. tonnic Avatar
    tonnic

    Anyone find a solution here? My /admin/config.php is also giving me a HTTP ERROR 500

  13. Tri Avatar
    Tri

    I do the same this page , it working but http://localhost/admin/config.php is blank please help me !!!

  14. Matt Avatar
    Matt

    I’m on ubuntu 18.04 and 127.0.0.1 redirects to blank page 🙁

  15. Mauricio Avatar
    Mauricio

    HI Guys, i got this error:

    admin-asterisk@adminasterisk-VirtualBox:/tmp/freepbx$ sudo ./install -n
    Assuming you are Database Root
    Checking if SELinux is enabled…Its not (good)!
    Reading /etc/asterisk/asterisk.conf…Done
    Checking if Asterisk is running and we can talk to it as the ‘asterisk’ user…Yes. Determined Asterisk version to be: 16.12.0
    Checking if NodeJS is installed and we can get a version from it…Yes. Determined NodeJS version to be: 10.22.0
    Preliminary checks done. Starting FreePBX Installation
    Checking if this is a new install…Yes (No /etc/freepbx.conf file detected)
    Error!
    PDO Driver ‘mysql’ is missing from the system

    Can anyone help me pls?

  16. Steve A Avatar
    Steve A

    Hi All,
    I got the following error message, can any one help please?

    STARTING ASTERISK
    Asterisk is already running
    root@freepbx:/tmp/freepbx# sudo ./install -n –dbuser root –dbpass type_root_password_here
    Assuming you are Database Root
    Checking if SELinux is enabled…Its not (good)!
    Reading /etc/asterisk/asterisk.conf…Done
    Checking if Asterisk is running and we can talk to it as the ‘asterisk’ user…Yes. Determined Asterisk version to be: 16.12.0
    Checking if NodeJS is installed and we can get a version from it…Yes. Determined NodeJS version to be: 10.22.0
    Preliminary checks done. Starting FreePBX Installation
    Checking if this is a new install…Yes (No /etc/freepbx.conf file detected)
    Error!
    PDO Driver ‘mysql’ is missing from the system

  17. Respati Avatar
    Respati

    for the blank page and permission denied on error log, you can try this one
    /etc/apache2/envvars

    change this line

    # export APACHE_RUN_USER=www-data
    # export APACHE_RUN_GROUP=www-data
    export APACHE_RUN_USER=asterisk
    export APACHE_RUN_GROUP=asterisk

    1. Angel Reynoso Avatar
      Angel Reynoso

      Excellent… Good.

    2. Ado Avatar
      Ado

      Works for me thanks a lot

    3. Nipun Avatar
      Nipun

      This is the perfect solution.

  18. David Avatar
    David

    There’s quite a few problems with this guide.

    1. I had to use PHP 7.3 to avoid installation issues. Both 7.2 and 7.4 gave errors.

    2. The biggest mistake in the instructions is including php-cas in the php installs. This will by default install PHP 7.4 as well, causing conflicts if you are using another version of PHP.

    3. Basically for people starting out with this, make sure whatever PHP library you install, it should coincide with your particular PHP version. Otherwise it will break stuff.

    Good luck guys, don’t give up! It works. I encountered almost every error mentioned in the comments and managed to fix them all.

  19. Leendert-Jan Avatar
    Leendert-Jan

    If you get a blank screen try setting the permissions again:
    sudo chmod 777 /var/www/html
    sudo chmod 777/var/log/asterisk

    Worked for me 🙂

    1. ALBERTO JR CASTOR LAMATA Avatar
      ALBERTO JR CASTOR LAMATA

      didnt work

  20. Blue Avatar
    Blue

    This doesn’t work at all. I was excited to have a PBX, I could spoof calls with scammers. I’m a scambaiting in need of a PBX on my VPS. They don’t allow mounting, but I need some help. Since I can’t get this guild to work, almost at my ends wits with this stuff. if anyone to could reach out to me with help, I would be in debt to you and also will share the spoofing macro with you.

  21. ALBERTO JR CASTOR LAMATA Avatar
    ALBERTO JR CASTOR LAMATA

    http://localhost/admin/config.php is a blank screen

  22. Dmitriy Avatar
    Dmitriy

    I do everything according to the instructions but I have php version 8.0.11

  23. Vikas Gupta Avatar
    Vikas Gupta

    After successfully installation, http://localhost/admin/config.php shows a blank page. Could anyone help please?

    Thanks

  24. Jason Avatar
    Jason

    Still getting a black page at after successfully installation, http://192.168.1.xxx/admin/config.php shows a blank page.

    Could anyone help please?

  25. Fajar Avatar
    Fajar

    Hello,
    I have error after run sudo ./install -n –dbuser root –dbpass type_root_password_here

    the response

    PHP Fatal error: Uncaught Error: Call to undefined function FreePBX\Install\simplexml_load_file() in /tmp/freepbx/install:19
    Stack trace:
    #0 {main}
    thrown in /tmp/freepbx/install on line 19

    could you help me???

  26. Nipun Avatar
    Nipun

    For all blank screen issues for the first run, please check this answer from the following user.

    Respati
    10/08/2020 at 8:57 PM

    for the blank page and permission denied on error log, you can try this one
    /etc/apache2/envvars

    change this line

    # export APACHE_RUN_USER=www-data
    # export APACHE_RUN_GROUP=www-data
    export APACHE_RUN_USER=asterisk
    export APACHE_RUN_GROUP=asterisk

Leave a Reply to Jim Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.