Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improvement]: Instructions to Use External MYSQL Server #147

Open
miljw002 opened this issue Dec 24, 2024 · 2 comments
Open

[improvement]: Instructions to Use External MYSQL Server #147

miljw002 opened this issue Dec 24, 2024 · 2 comments
Labels
triage Triage

Comments

@miljw002
Copy link

FreePBX Version

FreePBX 17

Improvement Description

FreePBX Version

FreePBX 17

Enhancement Description

The ability to use an external MYSQL server.

Operating Environment

Using the Freepbx 17 script Debian 12

I've spent some time reading the Wiki, issues, Google, ChatGPT and haven't been able to fully work it out myself.

I run a central MYSQL server for multiple services and would like to host the FreePBX DBs on there as well. I found partial instructions to export the current DB and import into my external MYSQL server, but I can't find all the locations to update in the FreePBX config.

Is it possible to get a list of the locations that have the DB connection strings stored, and how I need to update them to use an external MYSQL server?

I did a search across the config files and found multiple locations with connection details, but some say they are dynamically generated and not to touch them.

@miljw002 miljw002 added the triage Triage label Dec 24, 2024
@miljw002
Copy link
Author

miljw002 commented Dec 25, 2024

Hi All,

Providing an update. I've spent time digging around and I think I've worked out what was going on. I may be wrong, so if the developers can correct me I'm happy for more info.

  1. /etc/freepbx.conf

This file needed to have the updated MySQL connection settings in there (this was easy).

  1. /etc/odbc.ini
    Updated the details in there, but not 100% where they are used.

  2. /var/www/html/admin/bootstrap.php
    This seemed to be the trick. The database name seemed to be hardcoded in here.

if ($bootstrap_settings['cdrdb']) {
$dsn = array(
'phptype' => $amp_conf['CDRDBTYPE'] ? $amp_conf['CDRDBTYPE'] : $amp_conf['AMPDBENGINE'],
'hostspec' => $amp_conf['CDRDBHOST'] ? $amp_conf['CDRDBHOST'] : $amp_conf['AMPDBHOST'],
'username' => $amp_conf['CDRDBUSER'] ? $amp_conf['CDRDBUSER'] : $amp_conf['AMPDBUSER'],
'password' => $amp_conf['CDRDBPASS'] ? $amp_conf['CDRDBPASS'] : $amp_conf['AMPDBPASS'],
'port' => $amp_conf['CDRDBPORT'] ? $amp_conf['CDRDBPORT'] : '3306',
//'socket' => $amp_conf['CDRDBTYPE'] ? $amp_conf['CDRDBTYPE'] : 'mysql',
'database' => $amp_conf['CDRDBNAME'] ? $amp_conf['CDRDBNAME'] : 'asteriskcdrdb',
);
$cdrdb = DB::connect($dsn);
}

I edited it to use a variable from the config file, and then it seems to work.

if ($bootstrap_settings['cdrdb']) {
$dsn = array(
'phptype' => $amp_conf['CDRDBTYPE'] ? $amp_conf['CDRDBTYPE'] : $amp_conf['AMPDBENGINE'],
'hostspec' => $amp_conf['CDRDBHOST'] ? $amp_conf['CDRDBHOST'] : $amp_conf['AMPDBHOST'],
'username' => $amp_conf['CDRDBUSER'] ? $amp_conf['CDRDBUSER'] : $amp_conf['AMPDBUSER'],
'password' => $amp_conf['CDRDBPASS'] ? $amp_conf['CDRDBPASS'] : $amp_conf['AMPDBPASS'],
'port' => $amp_conf['CDRDBPORT'] ? $amp_conf['CDRDBPORT'] : '3306',
//'socket' => $amp_conf['CDRDBTYPE'] ? $amp_conf['CDRDBTYPE'] : 'mysql',
'database' => $amp_conf['CDRDBNAME'] ? $amp_conf['CDRDBNAME'] : $amp_conf['CDRDBNAME'],
);
$cdrdb = DB::connect($dsn);
}

If I then add the following to /etc/freepbx.conf it seems to start without errors.

$amp_conf["CDRDBNAME"] = "freepbxcdrdb";

I'm still checking/testing, but I think this may have fixed it. I realise modifying the php file may be dangerous, so more than happy to do it the correct way if I can be told what that is.

@miljw002
Copy link
Author

Nope, I needed to revert to using the internally hosted MySQL. When I tried to update modules I got SQL errors. Looks like there are multiple locations that need updating, and I'm not sure where they all are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Triage
Projects
None yet
Development

No branches or pull requests

1 participant