Upgraded to Latest RC and amportal is broken

Cannot start asterisk using amportal - getting

amportal start

/var/lib/asterisk/bin/freepbx_engine: line 98: Warning:: command not found
astrundir in ‘/etc/asterisk’ is set to but the directory
does not exists. Attempting to create it with: 'mkdir -p ’

mkdir: missing operand
Try `mkdir --help’ for more information.
Attempt to execute 'mkdir -p ’ failed with an exit code of 1
You must create this directory and the try again.

Prior to upgrade everything was ok - now everything is broken :frowning:
Could really do with some quick pointers here.

what did you upgrade from

what linux version are you using

what is your asterisk file structure (asterisk.conf settings)?

As I am unable to get into freepbx I cant tell you the revision - all I can say is that I upgraded today 2.09-RC2? from 08 (sorry cant be more specific).

cat /etc/*-release

astetcdir => /etc/asterisk
astmoddir => /usr/lib/asterisk/modules
astvarlibdir => /var/lib/asterisk
astagidir => /usr/share/asterisk/agi-bin
astspooldir => /var/spool/asterisk
astrundir => /var/run/asterisk
astlogdir => /var/log/asterisk

When accessing freepbx via browser I get

Unknown SQL engine: []

Trace Back

/var/www/admin/common/db_connect.php:57 die_freepbx()
[0]: Unknown SQL engine: []

/var/www/admin/bootstrap.php:66 require_once()
[0]: /var/www/admin/common/db_connect.php

/var/www/admin/config.php:61 require()
[0]: /var/www/admin/bootstrap.php

Hope that helps - really desperate to get a working system again :frowning:

you should know what you upgraded from or how you upgraded.

Did you use the Upgrade Module or did you upgrade using install_amp from the tarball? Of were you already running 2.9 beta before you upgraded to RC. It’s hard to provide guidance without that sort of information. (The other info you provided is good though).

somewhere along the way you did not get migrated properly. It could be bugs related to the less common configuration that you have (being Umbuntu though most of the important directories are pretty standard which is a bit puzzling).

In any event, getting it fixed through a forum discussion is probably going to be far fetched. Do you have a backup, because your first best thing to do would be to go back to the backup to get up and working and then re-group as to what the issues may be or get some more intense logging configured and then re-try the upgrade.

If not, you could try to pull the tarball and use install_amp with --force-version 2.8.0 (or what ever you may have upgraded from previously and see if that ends up forcing the migration to happen correctly. It’s a long shot but isn’t going to do any more harm then the current state by doing that.

A couple other questions depending on what the answers to the above are:

Do you have a table in SQL database called freepbx_settings and if so, how many entries do you have?

Do you have a file called /etc/freepbx.conf or /etc/asterisk/freepbx.conf and if so, is it empty or does it have something in it?

A couple other questions depending on what the answers to the above are:

Do you have a table in SQL database called freepbx_settings and if so, how many entries do you have?

Do you have a file called /etc/freepbx.conf or /etc/asterisk/freepbx.conf and if so, is it empty or does it have something in it?

Thank you for the fast response - I misunderstood what you meant about upgrading.
Yes I upgraded using the module in freepbx from 2.8 up to 2.9. I have upgraded before and during the upgrade everything appeared to install succesfully. Everything was working after the upgrade and I would not have known there was any problem (all extensions and trunks working) if I had not rebooted.

As for reverting to backup, yes I did do a backup via freepbx backup, and I do backup every night. As I cant get in to freepbx, I am a bit stuck as to how to restore.

ls -al /etc/free*
-rw-r–r-- 1 root root 0 2011-04-08 18:19 /etc/freepbx.conf
[email protected]:/etc# cat freepbx.conf
[email protected]:/etc#

Could freepbx.conf have the wrong permissions - normally asterisk:asterisk ?

In /etc/asterisk there is
-rw-r–r-- 1 asterisk asterisk 269 2011-04-08 14:30 freepbx.conf.bkup

which is the time of the upgrade today.

No sql database of that name :frowning:


that would be a sql table in the normal asterisk database, not an entire database.

I didn’t think we made any sort of backup of freepbx.conf to freepbx.conf.bkup, I would have to look through the code to see if that is the case.

Bottom line though, are you saying your freepbx.conf file is empty? If so, that is a bit of a problem and could be related to or the root of your issues, though I don’t know why it would be empty.

It should look something like this:

<?php $amp_conf['AMPDBUSER'] = 'freepbx_user'; $amp_conf['AMPDBPASS'] = 'freepbx_password'; $amp_conf['AMPDBHOST'] = 'localhost'; $amp_conf['AMPDBNAME'] = 'asterisk'; $amp_conf['AMPDBENGINE'] = 'mysql'; $amp_conf['datasource'] = ''; //for sqlite3 require_once('/var/www/html/admin/bootstrap.php'); [/php] where the freepbx_user/freepbx_password would be your database credentials. However, if you have that but you don't have a table called freepbx_settings then something went wrong and it won't work. The freepbx.conf file is now the only configuration file used to 'boostrap' freepbx. We no longer use amportal.conf (though it is still there for legacy reasons. All the settings that were in amportal.conf, with the exception of those above, are now in the freepbx_settings table. So both need to be there for anything to work.

Thank you Philippe

Have checked

cat /etc/asterisk/freepbx.conf.bkup

<?php $amp_conf['AMPDBUSER'] = "asteriskuser"; $amp_conf['AMPDBPASS'] = "xxxx"; $amp_conf['AMPDBHOST'] = "localhost"; $amp_conf['AMPDBNAME'] = "asterisk"; $amp_conf['AMPDBENGINE'] = "mysql"; $amp_conf['datasource'] = ""; require_once('/var/www/admin/bootstrap.php'); xxxx replaces my real password :) I have done a cp /etc/asterisk/freepbx.conf.bkup /etc/freepbx.conf Have checked and freepbx_settings has 29 rows. AND..... amportal start is now working - THANK YOU SIR :) Now I am happy. Also getting a bit late here in the UK.

not sure what went wrong but good you are up.

Only 29 rows for freepbx_settings sounds like something went south as there should be a lot more then that.

You may want to force re-install the framework module from online, that will probably get you your other freepbx_settings that should be in there.

Apologies - it was getting late.
Just re-checked using phpmyadmin and it was displaying

Showing rows 0 - 29 175 total

You are correct - 175 rows - I miss-read the message :slight_smile:

System appears fine now - thank you once again for the fast response.

I am on FreePBX 2.9.0rc1.2
When moving from 2.8, it was a two stage process 2,8 to 2.9.0rc1.1 to 2.9.0rc1.2 (pretty sure that was the order).
I did not see any errors during the upgrade and as mentioned everything was working until the reboot.

This was a very strange one. If there were bread crumbs to follow what happened it would be useful since a bug in the migration process is obviously not out of the question.

As far as upgrading, the process involves:

[]Upgrade Button in the module which points module admin to the new repo
]Upgrade framework module which was probably the 2.9.0rc1.1 you saw
[*]Upgrade core module which was probably the 2.9.0rc1.2 you saw

and of course after that upgrading everything else…

The process of upgrading the framework module runs through the critical migrations that are responsible for setting up your freepbx.conf file and moving all your settings to the freepbx_settings table. Clearly some of that worked, just not sure how you ended up with the empty freepbx.conf in /etc which is the first one that is looked at, where as /etc/asterisk is looked at if that doesn’t exist (which would be the case if we didn’t have write permission at the time of migration into /etc).

The processes I followed were as you described :-

Upgrade module.
Upgrade framework
Upgrade core (and other modules)
Noticed 2.9.0rc1.2 so upgraded again
Then updated all modules again.

Pretty sure that is accurate - but after the panic and the late night…

I am going to take a ghost backup tonight !!!

Understand the comments about permissions - as I mentioned

-rw-r–r-- 1 root root 0 2011-04-08 18:19 /etc/freepbx.conf

Did look suspicious.

One thing we can say is that if the upgrade fails under these conditions the effects are dramatic but the displayed errors did not help much - you were the star Philippe :slight_smile:

assuming your browser is running as user asterisk, then the /etc/freepbx.conf file may have already been there.

Since you upgraded through the browser, it would otherwise be impossible to have root/root ownership (unless that is how your browser is configured).

The only way that it could otherwise be root/root ownership is if your call to amportal (freepbx_engine) subsequently created that and didn’t get around to changing the ownership to asterisk/asterisk before the crash happened since amportal is run by root.

It remains a mystery. I would love to know what ultimately happened but given how isolated this is, I probably don’t have the time to dig deeper on your system with you and see what potential logs and other things might show (and it’s likely that the info just isn’t there :frowning: )

I’m glad you are up, that part is good :slight_smile: - I’ve got notes to re-visit some of our checks and see if we could do a better job then just checking for the existence of the freepbx.conf file before choosing that is the one to use, though it’s likely enough of a corner case that things will stay the way they are…

I’m having the exact same problem after downgrading php components!

How was it fixed? My phone system runs fine, but I can’t change anything because FreePBX is down! :frowning:


My guess is that somehow the PEAR DB went missing or corrupt. It’s happened to me for no explainable reason. The result is that amportal can’t connect to the database. My suggestion for others that stumble upon this:


After some googling around I found this topic that is almost similar to my problem, but in my case the /etc/freepbx.conf is not missing.

I have installed FreePBX on Debian Squeeze using the script from http://www.corenetworks.com.au/wiki/doku.php?id=debian_asterisk_freepbx_script. This worked great and gave me FreePBX v2.8.1. Then I upgraded to the latest v2.8 from the ‘Module Admin’ and installed some extra modules. After that I upgraded to v2.9.0.7 following the ‘2.9 Upgrade Tool’. It seemed to work, but after a reboot Asterisk is not running anymore. I can access the FreePBX web GUI.

The terminal on boot (I added some output):

Starting FreePBX ...


@freepbx_engine: ASTRUNDIR = --
/var/lib/asterisk/bin/freepbx_engine: line 102: [FATAL]: command not found
astrundir in '/etc/asterisk' is set to  but the directory
does not exists. Attempting to create it with: 'mkdir -p '

mkdir: missing operand
Try `mkdir --help' for more information.
Attempt to execute 'mkdir -p ' failed with an exit code of 1
You must create this directory and the try again.
Starting MySQL database server: mysqld.
Checking for corrupt, not cleanly closed and upgrade needing tables..

Debian GNU/Linux 6.0 pbx ttyS0

pbx login:

When I open a SSH connection to the box and start the amportal manually (amportal start), asterisk starts and it looks like everything is OK again.

Could someone give me a hint what is wrong here? And how to solve this? I am new to FreePBX so please be gentle ;-).

I also tried

pear install DB

but this gave me

No releases available for package "pear.php.net/DB"
install failed

Is this because the box is behind a proxy?

Hope that we can find a solution!

You’re close in your config, but your system is still missing some php/pear hooks to get to mysql and access the config in the table. I’m not familiar with the debian packaging or where the it’s pear release is published, but if you can get the install to succeed I’ll bet your system will be good to go.

Thanks for your response! I’m afraid you lose the bet ;-).

Found that PEAR DB can be installed with apt-get, but it was already there:

[email protected]:~# apt-get install php-db
Reading package lists... Done
Building dependency tree
Reading state information... Done
php-db is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

And in PEAR:

[email protected]:~# pear list
Installed packages, channel pear.php.net:
Package          Version State
Archive_Tar      1.3.7   stable
Console_Getopt   1.2.3   stable
DB               1.7.13  stable
PEAR             1.9.1   stable
Structures_Graph 1.0.3   stable
XML_Util         1.2.1   stable

Looking at the console output, I see that the MySQL server (mysqld) is started AFTER FreePBX tries to start. Could this cause the problem?