DB::connect() non static in class freepbx_db

Official Response Below:

Help me please…
I trying to install FreePBX on CentOS on this guide.
Sangoma Documentation .
command ./install_amp --installdb --username=asteriskuser --password=${ASTERISK_DB_PW}

PHP Fatal error: Cannot make static method DB::connect() non static in class freepbx_db in /var/www/html/admin/libraries/freepbx_DB.php on line 57

Tried to install on a centos 7. The same result…

pear.php.net/package/DB
This package has been superseded, but is still maintained for bugs and security fixes. Use MDB2 instead.

Only use PearDB do not use MDB2 this has been the case for 7+ years.

I installed old version. pear install DB-1.7.14

Looks like PearDB released an update to some depreciated libraries we use that breaks FreePBX, so for the time being you’ll need to use an older version of PearDB. I have fixed this in our wikis.

Contrary to popular internet theories this was not a change or “improvement” made from FreePBX. It was instead a change from an upstream provider of a database abstraction layer FreePBX has been using for several years.

As for the future. We have already started writing FreePBX 13 without the need for the PearDB libraries.

The FreePBX Distro is unaffected by this because of our use of RPMs which we maintain outside of the Pear channels.

These commands might get you going but since the database commands were unable to run you might have to start over

pear uninstall db
pear install db-1.7.14

I was just about to post a huge long post when I finally found this post. I am having the same problem while running the PiaF3 Installer. Everything completed but I got multiple errors like what you reported. When I tried to get into FreePBX Admin it just gave me a blank page after accepting my credentials.

During the installer and then when running “amportal a dbug”:

PHP Fatal error: Cannot make static method DB::connect() non static in class freepbx_db in /var/www/html/admin/libraries/freepbx_DB.php on line 57

I tried to run “pear install DB-1.7.14” but it complained the DB was already installed. I then ran “pear uninstall db” and then ran “pear install DB-1.7.14”.

This actually resolved my problem with PiaF. I will repost over in their forums when Ward grants my new account access.

Thank you very much for posting and finding the problem!

1 Like

I was following the instructions for installing FreePBX from the wiki and was working up until starting asterisk and installing FreePBX the install_amp command checks for the PEAR DB and passes (it’s installed) but then gets several of the following DB::connect() errors from freepbx_db.php

PHP Fatal error: Cannot make static method DB::connect() non static in class freepbx_db in /var/www/htmls/freepbx_DB.php on line 57

here is some snippets from the install output. The user and pass has been set in mysql and is valid. Any help would be appreciated. Thanks!

[root@linux2361 freepbx]# ./install_amp --username=asteriskuser --password=$ASTERISK_DB_PW
Checking for PEAR DB…OK
Checking for PEAR Console::Getopt…OK
Using username: asteriskuser
Using password: ******
Checking user…OK
Checking if Asterisk is running…running with PID: 17366…OK

---------------- omitted section ----------------------

OK (227 files copied, 0 skipped)
amportal…no fpbx…freepbx_engine…freepbx_setting…gen_amp_conf.php…done
PHP Fatal error: Cannot make static method DB::connect() non static in class freepbx_db in /var/www/html/admin/libraries/freepbx_DB.ph
mkdir: missing operand
Try `mkdir --help’ for more information.
PHP Fatal error: Cannot make static method DB::connect() non static in class freepbx_db in /var/www/html/admin/libraries/freepbx_DB.ph
PHP Fatal error: Cannot make static method DB::connect() non static in class freepbx_db in /var/www/html/admin/libraries/freepbx_DB.ph
PHP Fatal error: Cannot make static method DB::connect() non static in class freepbx_db in /var/www/html/admin/libraries/freepbx_DB.ph
PHP Fatal error: Cannot make static method DB::connect() non static in class freepbx_db in /var/www/html/admin/libraries/freepbx_DB.ph
PHP Fatal error: Cannot make static method DB::connect() non static in class freepbx_db in /var/www/html/admin/libraries/freepbx_DB.ph
PHP Fatal error: Cannot make static method DB::connect() non static in class freepbx_db in /var/www/html/admin/libraries/freepbx_DB.ph
apply username/password changes to conf files:
running apply_conf.sh from freepbx_settings
PHP Fatal error: Cannot make static method DB::connect() non static in class freepbx_db in /var/www/html/admin/libraries/freepbx_DB.ph
sed: can’t read /manager.conf: No such file or directory
sed: can’t read /manager.conf: No such file or directory

You need to start over from scratch. All of the wikis have been updated. but first run this

pear uninstall db
pear install db-1.7.14

Do you have a current wiki link? I am installing FreePBX 2.11 on CentOS 6.3 per the wiki link I found (would paste but site does not allow it). If another CentOS and FreePBX version is better to install I can use those.

Thanks!

Refresh the wiki page. you will see the updates.

Thanks! That worked.

Yes, thank you very much! This worked for me too.

I had upgraded framework only from 2.10 to 2.11 using the upgrade module but lost the GUI. Phones appeared to be working fine. Could get a login box in IE, but not in Chrome interestingly. Ran “amportal start” and was getting the exact same as user kiran above. Ran the following commands as suggested and all works.

pear uninstall db
pear install db-1.7.14

Going back in to upgrade all other modules now.
Thanks very much.

1 Like