Need assistance setting up on Raspberry Pi. Blank config.php page

I’m having trouble loading FreePBX Administration. After login, I am presented with a blank page ( I’ve cleared my cache and tried multiple browsers from two different machines.

I’ve followed a guide found here:

Version numbers:
FreePBX 2.9.0
Apache/2.2.22 (Debian)
PHP Version 5.4.4-7
MySQL 5.5.24-9 (Debian)
Linux raspberrypi 3.2.27+ #160 PREEMPT Mon Sep 17 23:18:42 BST 2012 armv6l GNU/Linux

[code][email protected] /usr/src $ pear list
Installed packages, channel

Package Version State
Archive_Tar 1.3.7 stable
Console_Getopt 1.3.0 stable
DB 1.7.14 stable
PEAR 1.9.4 stable
Structures_Graph 1.0.4 stable
XML_Util 1.2.1 stable[/code]

Error messages:
After amportal start I receive the following in my command prompt:

/var/log/apache2# amportal startdefined(%hash) is deprecated at /var/www/panel/ line 2723. (Maybe you should just omit the defined()?)

Additional information:
FOP loads
Reports loads

snippet from /var/log/apache2/error.log

snippet from /var/log/apache2/access.log - admin [05/Oct/2012:18:37:03 +0000] "GET /admin/config.php HTTP/1.1" 200 466 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.13 (KHTML, like Gecko) Chrome/24.0.1283.0 Safari/537.13" - - [05/Oct/2012:18:37:03 +0000] "GET /favicon.ico HTTP/1.1" 404 502 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.13 (KHTML, like Gecko) Chrome/24.0.1283.0 Safari/537.13" - admin [05/Oct/2012:18:37:18 +0000] "GET /admin/config.php HTTP/1.1" 200 466 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.13 (KHTML, like Gecko) Chrome/24.0.1283.0 Safari/537.13" - admin [05/Oct/2012:18:37:21 +0000] "GET /admin/config.php HTTP/1.1" 200 465 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.13 (KHTML, like Gecko) Chrome/24.0.1283.0 Safari/537.13"

Output of PHP test page:

All FreePBX modules are up to date, but I run into an issue when I try and reload them:

[code][email protected] /var/log $ sudo -u asterisk /var/lib/asterisk/bin/module_admin upgradeall
no repos specified, using: [standard] from last GUI settings

Up to date.

[email protected] /var/log $ sudo -u asterisk /var/lib/asterisk/bin/module_admin reload
Error(s) have occured, the following is the retrieve_conf output:
exit: 255

snippet from /tmp/freepbx_debug.log

2012-Oct-05 21:57:20	/var/www/admin/views/freepbx.php:195
[NOTICE]: Undefined variable: module_name

2012-Oct-05 21:57:20	/var/www/admin/views/freepbx.php:236
[NOTICE]: Undefined index: USE_PACKAGED_JS

2012-Oct-05 21:57:20	/var/www/admin/views/freepbx.php:386
[NOTICE]: Undefined index: FOPDISABLE


[2012-Oct-05 16:54:27] [INFO] (freepbx-2.9.0/libfreepbx.install.php:170) - -> Running PHP script /usr/src/freepbx-2.9.0/upgrades/2.8.0/custom-context.php
[2012-Oct-05 16:54:27] [INFO] (freepbx-2.9.0/libfreepbx.install.php:113) - Upgrading to 2.8.0..OK
[2012-Oct-05 16:54:27] [INFO] (freepbx-2.9.0/libfreepbx.install.php:108) - Upgrading to 2.8.1..
[2012-Oct-05 16:54:27] [INFO] (freepbx-2.9.0/libfreepbx.install.php:113) - Upgrading to 2.8.1..OK
[2012-Oct-05 16:54:27] [INFO] (freepbx-2.9.0/libfreepbx.install.php:108) - Upgrading to 2.9.0alpha1..
[2012-Oct-05 16:54:27] [INFO] (freepbx-2.9.0/libfreepbx.install.php:170) - -> Running PHP script /usr/src/freepbx-2.9.0/upgrades/2.9.0alpha1/migrate_ampconf.php
[2012-Oct-05 16:54:27] [INFO] (2.9.0alpha1/migrate_ampconf.php:50) - Checking for freepbx_settings table..exists
[2012-Oct-05 16:54:27] [INFO] (2.9.0alpha1/migrate_ampconf.php:56) - Add field sortorder to freepbx_settings..Not Required
[2012-Oct-05 17:44:00] [FATAL] (common/db_connect.php:63) - die_freepbx(): DB Error: connect failed
[2012-Oct-05 17:44:01] [FATAL] (common/db_connect.php:63) - die_freepbx(): DB Error: connect failed

Also of note, when I try to load FreePBX Administration (is this the same thing as AMI?) I am prompted to enter some credentials. Even though I selected my own password (8 characters consisting of letters, numbers, and a -) when I ran install.amp I have to use the default username/password combo of admin/admin. I’ve logged into the MySQL database and I have confirmed that AMPMGRUSER=admin, AMPMGRPASS=my password and AUTHTYPE is set to database. Maybe I’m looking at the wrong username/password pair.

Thanks for any and all assistance.

The AMP paramaeters are for the Asterisk manager interface, not for users.

You need to simply use the FreePBX administrators module to add/delete/modify (including default admin account).

Thanks, but when I try to access the FreePBX administrators module I get a blank config.php page. Any ideas what is causing that?

I’m uber security minded :slight_smile: Putting up a copy of your PHPinfo someplace is definitely a better idea… one thing you don’t want is someone having enough info to be able to break into your VOIP server! People can wind up with thousands of dollars of billing that way if they have a trunk hooked up.

All the debug info is pointed to the same basic problem: the includes/requires are definitely not being picked up by the php pages as they should be, either because of a bad location definition somewhere or file permission issues. You might want to chuck “echo $_SERVER[‘DOCUMENT_ROOT’];” into a test file and see what it pumps out and compare it to the paths being used in the FreePBX files.

It would also be more useful to check permissions/ownership with “ls -la /var/www/”. Just because a file can be listed with “ls” doesn’t mean that it can be read. If memory serves, the apache user also needs to own /var/www as well.

Finally, you might want to double check that it is indeed the asterisk user that is running Apache using “ps -aux | grep apache2”

FYI, having a phpinfo() page available publicly like that is a super bad idea…

If you’re getting a page with a blank source, it sounds like a PHP error to me. It’s odd that you’re not getting any error messages and you have error reporting turned on … Try setting “error_log”, so that you can have a log file to check for PHP errors while you’re troubleshooting.

If you’re getting “[NOTICE]: Undefined variable:…”, that generally means that their is a permissions or pathing problem with the FreePBX files. Have you explicitly set the webserver instance user to asterisk, or made sure that the files are accessible to whatever user you do have set?

The “[FATAL] (common/db_connect.php:63) - die_freepbx(): DB Error: connect failed” is definitely problematic. If I remember correctly, the un/pw are in /etc/freepbx.conf. Check that those are correct, and that the user privs allow localhost login.

Thanks for your concern about phpinfo(), but considering I won’t be granting internet access to this server and I haven’t posted my external IP address I’ll take my chances. The linked phpinfo() is a copy of the one generated by my server, now hosted at dropbox. Plus maybe it’s helpful in troubleshooting my issue?

Regarding point 1:

In /etc/amportal I set DEVEL=TRUE and rebooted. Here’s the new /tmp/freepbx_debug.log. I think it’s a lot more informational, but I’m still digesting it.

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:55

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:60

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:63

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:67
[NOTICE]: Undefined index: AMPADMINLOGO

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:70

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:72

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:73

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:74

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:75

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:76

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:77

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:78

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:79

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:81

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:82
[NOTICE]: Undefined index: BRAND_CSS_CUSTOM

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:84

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:85
[NOTICE]: Undefined index: AMPWEBROOT

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:90
[WARNING]: stat(): stat failed for /admin/common/mainstyle.css

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:109
[WARNING]: file_get_contents(/admin/common/mainstyle.css): failed to open stream: No such file or directory

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:113
[WARNING]: file_put_contents(/admin/common/mstyle_autogen_.css): failed to open stream: No such file or directory

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:195
[NOTICE]: Undefined variable: module_name

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:236
[NOTICE]: Undefined index: USE_PACKAGED_JS

2012-Oct-06 12:01:35    /var/www/admin/views/freepbx.php:386
[NOTICE]: Undefined index: FOPDISABLE

Also of note, I loaded and received the following error:

Fatal error: Call to undefined function get_framework_version() in /var/www/admin/views/freepbx.php on line 52

This is confirmed in /var/log/apache2/error.log

[Sat Oct 06 16:16:50 2012] [error] [client] PHP Fatal error:  Call to undefined function get_framework_version() in /var/www/admin/views/freepbx.php on line 52

Regarding point 2:

I’ve set the following in /etc/apache2/apache2.conf :

User asterisk
Group asterisk

I’ve also confirmed that the asterisk user can access files in /var/www/admin :

[email protected] /var/www/admin $ sudo -u asterisk bash
[email protected]:/var/www/admin$ ls
assets	bootstrap.php  cdr  common  config.php  helpers  i18n  images  index.php  libraries	module-builtin.xml  modules  page.modules.php  panel.php  reports.php  views
[email protected]:/var/www/admin$ vim config.php 

Regarding point 3:

You’re correct, the u/p are stored in /etc/freepbx.conf. But I’m not sure what was causing that error. The credentials are correct and the error no longer shows up after reboot. Odds are I caused that error while I was messing with something else. I’m going to ignore the error until it happens again.

Thank you so much for your help so far!

I appreciate your concern. Yeah, this is just a little hobby thing to get a rotary phone hooked up to Google Voice. No trunk lines involved. :slight_smile:

“echo $_SERVER[‘DOCUMENT_ROOT’];” results

This matches all but one of the values in /etc/amportal.conf. Do I need to repoint the cgi-bin directory?

# CGI Dir
# Default Value: /var/www/cgi-bin

# FreePBX Web Root Dir
# Default Value: /var/www/html

# FOP Web Root Dir
# Default Value: /var/www/html/panel

I’ve confirmed that the asterisk user is indeed running Apache

ps | grep apache2
root      6101  0.0  4.5  42612  8572 ?        Ss   17:33   0:01 /usr/sbin/apache2 -k start
asterisk  6121  0.0  3.0  42744  5788 ?        S    17:33   0:00 /usr/sbin/apache2 -k start
asterisk  6122  0.0  4.6  45236  8764 ?        S    17:33   0:00 /usr/sbin/apache2 -k start
asterisk  6123  0.0  3.0  42760  5824 ?        S    17:33   0:00 /usr/sbin/apache2 -k start
asterisk  6124  0.0  2.9  42712  5644 ?        S    17:33   0:00 /usr/sbin/apache2 -k start
asterisk  6125  0.0  2.8  42696  5324 ?        S    17:33   0:00 /usr/sbin/apache2 -k start
asterisk  6276  0.0  2.8  42696  5328 ?        S    17:34   0:00 /usr/sbin/apache2 -k start
asterisk  6277  0.0  5.0  45228  9500 ?        S    17:34   0:00 /usr/sbin/apache2 -k start
asterisk  6278  0.0  5.2  46260 10020 ?        S    17:34   0:01 /usr/sbin/apache2 -k start
asterisk  6283  0.0  2.4  42636  4644 ?        S    17:34   0:00 /usr/sbin/apache2 -k start
asterisk  6284  0.0  2.4  42636  4628 ?        S    17:34   0:00 /usr/sbin/apache2 -k start
chris     6816  0.0  0.4   3532   808 pts/0    S+   19:58   0:00 grep --color=auto apache2

It appears that asterisk has the appropriate rights, but I need to look into how to give the Apache user their own /var/www

[email protected] /var $ ls -la /var/www/
total 48
drwxr-xr-x  6 root     root     4096 Oct  6 20:05 .
drwxr-xr-x 12 root     root     4096 Oct  4 08:41 ..
drwxrwxrwx  9 asterisk asterisk 4096 Oct  6 17:32 admin
drwxrwxrwx  2 asterisk asterisk 4096 Oct  4 09:21 _asterisk
-rwxrwxrwx  1 root     root      545 Oct  6 17:31 index.html
-rwxrwxrwx  1 root     root     4542 Oct  6 17:31 mainstyle.css
drwxrwxrwx  6 asterisk asterisk 4096 Oct  4 10:40 panel
-rw-r--r--  1 root     root       42 Oct  6 20:04 phptest2.php
-rw-r--r--  1 root     root       21 Oct  5 17:48 phptest.php
drwxrwxrwx  7 asterisk asterisk 4096 Oct  6 17:31 recordings
-rwxrwxrwx  1 root     root      361 Oct  6 17:31 robots.txt

I feel as if I am very close to a solution, which is what makes this whole thing so frustrating. :slight_smile:

A quick question before you go too far, How will you get a rotary phone hooked up to a RaspberryPI without an FXS interface that will recognize line pulses? Dahdi can with a little persuasion otherwise you will need an ATA that can do that, I personally don’t know of one.

I’ve had it hooked up previously using Gizmo5 and a Grandsteam HT-502 ATA.

Plus there’s no such thing as going too far. This is a learning experience. :slight_smile:

Then you have my support, go for it!! FreePBX puts nothing in cgi-bin. But FreePBX is redhat friendly and not so much Debian, I suggest you move your document_root to /var/www/html as there are some still hardcoded references to that location that the install script doesn’t take care of, so watch you users php, apache2, document_root and asterisk and it’s home directory’s permissions as logos says.