Wednesday, December 21, 2016

How to Install Asterisk and FreePBX on Ubuntu Server 16.04 Xenial with a MySQL root Password

So FreePBX "recommends" to not set a password for your MySQL root user, and leave it blank. I'm not sure how anyone could justify that leaving a password blank is a good recommendation. I don't care if your server is only listening on localhost or (hopefully not) facing the internet, this is a horrible recommendation, and it really makes me concerned with the quality the FreePBX code. Well, I decided to try out FreePBX anyway and had a lot of trouble figuring out how to configure it to use a password for mysql. I started grepping through the source code and finally hit pay dirt after using this command:
grep -R "Database Root" .
This told me that the code checking for connectivity to the database is in the file:
./installlib/installcommand.class.php
After opening this file, I was presented with the code where it stores its database settings
I changed line 33 to use my root database password:
'dbpass' => array(
'default' => 'your_mysql_root_password_goes_here',
'description' => 'Database password',
After re-running:
sudo ./install -n
It failed. damnit! But this time, it gives shows me all the flags that the install script accepts:
--dbuser Database username (default: "root")
--dbpass Database password (default: "")
Aha! And to see a full list of command line options, you can run the install script like so:
./install -h
Now to try again:
./install -n --dbuser="root" --dbpass="your_db_password_goes_here"
Annnnd... it worked!
I didn't notice anything in the documentation talking about the install scripts help or config flags, so I thought I'd post them here:
PHP Warning: Declaration of FreePBX\Install\FreePBXHelpCommand::setCommand(FreePBX\Install\FreePBXInstallCommand $command) should be compatible with Symfony\Component\Console\Command\HelpCommand::setCommand(Symfony\Component\Console\Command\Command $command) in /opt/freepbx/installlib/installhelpcommand.class.php on line 15
______ _____ ______ __
| ____| | __ \| _ \ \ / /
| |__ _ __ ___ ___| |__) | |_) \ V /
| __| '__/ _ \/ _ \ ___/| _ < > <
| | | | | __/ __/ | | |_) / . \
|_| |_| \___|\___|_| |____/_/ \_\
Usage:
install [--dbengine="..."] [--dbname="..."] [--cdrdbname="..."] [--dbuser="..."] [--dbpass="..."] [--user="..."] [--group="..."] [--dev-links] [--webroot="..."] [--astetcdir="..."] [--astmoddir="..."] [--astvarlibdir="..."] [--astagidir="..."] [--astspooldir="..."] [--astrundir="..."] [--astlogdir="..."] [--ampbin="..."] [--ampsbin="..."] [--ampcgibin="..."] [--ampplayback="..."] [-r|--rootdb] [-f|--force]

Options:
--dbengine Database engine (default: "mysql")
--dbname Database name (default: "asterisk")
--cdrdbname CDR Database name (default: "asteriskcdrdb")
--dbuser Database username (default: "root")
--dbpass Database password (default: "")
--user File owner user (default: "asterisk")
--group File owner group (default: "asterisk")
--dev-links Make links to files in the source directory instead of copying (developer option)
--webroot Filesystem location from which FreePBX files will be served (default: "/var/www/html")
--astetcdir Filesystem location from which Asterisk configuration files will be served (default: "/etc/asterisk")
--astmoddir Filesystem location for Asterisk modules (default: "/usr/lib/asterisk/modules")
--astvarlibdir Filesystem location for Asterisk lib files (default: "/var/lib/asterisk")
--astagidir Filesystem location for Asterisk agi files (default: "/var/lib/asterisk/agi-bin")
--astspooldir Location of the Asterisk spool directory (default: "/var/spool/asterisk")
--astrundir Location of the Asterisk run directory (default: "/var/run/asterisk")
--astlogdir Location of the Asterisk log files (default: "/var/log/asterisk")
--ampbin Location of the FreePBX command line scripts (default: "/var/lib/asterisk/bin")
--ampsbin Location of the FreePBX (root) command line scripts (default: "/usr/sbin")
--ampcgibin Location of the Apache cgi-bin executables (default: "/var/www/cgi-bin")
--ampplayback Directory for FreePBX html5 playback files (default: "/var/lib/asterisk/playback")
--rootdb (-r) Database Root Based Install. Will create the database user and password automatically along with the databases
--force (-f) Force an install. Rewriting all databases with default information
--help (-h) Display this help message
--quiet (-q) Do not output any message
--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
--version (-V) Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
--no-interaction (-n) Do not ask any interactive question

No comments:

Post a Comment