Community
OpenEnergyMonitor

Community

Settings.php file error

Morning, clicked on update Emonpi this morning from the admin page, i now get -

**
settings.php file error

settings.php config file has new settings for this version. Copy default.settings.php to settings.php and modify the later.

To fix, check that the settings are set in settings.php or try re-creating your settings.php file from default.settings.php template
**

are there any quick fixes to get me up and running again? cheers

I had the same problem as well. The error message helps, but of course unless you know where these files are and what changes to make it can be a challenge. I did a backup before the update so had a copy of the old file just in case. The files are in the /var/www/emoncms on the pi (at least in my installation). You also need to change the system to read-write with rpi-rw.

If you can open them in an editor - like nano - it is easy to see what needs changing (I printed mine so I could go through line by line). I renamed my existing settings.php to old_settings.php just in case.

The default.settings.php file needs to be slightly modified to include some specific variables which you can copy from your existing settings.php file. These are like the mysql database username and password (the very first block in the file). A couple of other blocks also need modifying (email SMTP if used). When you have made the changes save it as settings.php and return the system to read only with rpi-ro. It should then restart with no problems!

Thanks for the reply, i tried to change the username and password but no luck, now many other fields need changing? Please could you share your settings (removing confidential info :slight_smile:)

//1 #### Mysql database settings
$server = “localhost”;
$database = “emoncms”;
$username = “DB_USER”;
$password = “DB_PASSWORD”;
$port = “3306”;
// Skip database setup test - set to false once database has been setup.
$dbtest = true;

Sorry - I’m 500 km from my system at the moment and can’t ssh into it at the moment. But I recall there was another field towards the end. Maybe someone else can help? I’ll be back Friday and will check then. Did you reboot?

I have this exact same problem. How do you change the config files? I try to log into the emonpi through CMS and just keep getting the error message. I assume the file is in the firmware, because I pulled the pi apart and checked the SD card and it’s definitely not there!

Here is my settings file:


<?php

//1 #### Mysql database settings
    $server   = "localhost";
    $database = "emoncms";
    $username = "********";
    $password = "*********";
    $port     = "3306";
    // Skip database setup test - set to false once database has been setup.
    $dbtest = true;


//2 #### Redis
    $redis_enabled = true;
    $redis_server = array( 'host'   => 'localhost',
                           'port'   => 6379,
                           'auth'   => '',
                           'prefix' => 'emoncms');


//3 #### MQTT
    // The 'subscriber' topic format is rx/* - where * is the emoncms input node number.
    // The 'publisher' topic format is user selectable from the 'Publish to MQTT' input process, for example power/solar
    $mqtt_enabled = true;          // Activate MQTT by changing to true
    $mqtt_server = array( 'host'     => 'localhost',
                          'port'     => 1883,
                          'user'     => 'emonpi',
                          'password' => '*******',
                          'basetopic'=> 'emon'
                          );


//4 #### Engine settings
    $feed_settings = array(
        // Supported engines. Uncommented engines will not be available for user to create a new feed using it. Existing feeds with a hidden engine still work.
        // Place a ',' as the first character on all uncommented engines lines but first.
        // If using emoncms in low-write mode, ensure that PHPFIWA is disabled by removing the leading //, from the PHPFIWA entry
        'engines_hidden'=>array(
            //Engine::MYSQL         // 0  Mysql traditional
            //Engine::MYSQLMEMORY   // 8  Mysql with MEMORY tables on RAM. All data is lost on shutdown
            //Engine::PHPTIMESERIES // 2
            //,Engine::PHPFINA      // 5
            //,Engine::PHPFIWA      // 6
        ),

        // Redis Low-write mode
        'redisbuffer'=>array(
            'enabled' => true      // If enabled is true, requires redis enabled and feedwriter service running
            ,'sleep' => 60          // Number of seconds to wait before write buffer to disk - user selectable option
        ),

        'csvdownloadlimit_mb' => 25,     // Max csv download size in MB

        // Engines working folder. Default is /var/lib/phpfiwa,phpfina,phptimeseries
        // On windows or shared hosting you will likely need to specify a different data directory--
        // Make sure that emoncms has write permission's to the datadirectory folders
        'phpfiwa'=>array(
            'datadir' => '/home/pi/data/phpfiwa/'
        ),
        'phpfina'=>array(
            'datadir' => '/home/pi/data/phpfina/'
        ),
        'phptimeseries'=>array(
            'datadir' => '/home/pi/data/phptimeseries/'
        )
    );

    // Max number of allowed different inputs per user. For limiting garbage rf data
    $max_node_id_limit = 32;


//5 #### User Interface settings
    // Theme location (folder located under Theme/, and must have the same structure as the basic one)
    $theme = "basic";

    // Favicon filenme in Theme/$theme
    $favicon = "favicon.png";

    // Use full screen width
    $fullwidth = true;

    // Main menu collapses on lower screen widths
    $menucollapses = false;

    // Enable multi user emoncms.
    // If set to false, emoncms will automatically remove the register form and
    // ability to create further users after the first user has been created
    $enable_multi_user = false;

    // Enable remember me feature
    $enable_rememberme = true;

    // Allow user to reset his password
    $enable_password_reset = false;

    // (OPTIONAL) Email SMTP, used for password reset or other email functions
    $smtp_email_settings = array(
      'host'=>"smtp.googlemail.com",
      'port'=>"465",  // 25, 465, 587
      'from'=>array('[email protected]' => 'EmonCMS'),
      // comment lines below that dont apply
      'encryption'=>"ssl", // ssl, tls
      'username'=>"********@gmail.com",
      'password'=>"*********"
    );

    // Default controller and action if none are specified and user is anonymous
    $default_controller = "user";
    $default_action = "login";

    // Default controller and action if none are specified and user is logged in
    $default_controller_auth = "feed";
    $default_action_auth = "list";

    // Public profile functionality
    // Allows http://yourdomain.com/[username]/[dash alias] or ?id=[dash id]
    // Alternative to http://yourdomain.com/dashboard/view?id=[dash id]
    // Add optional '&embed=1' in the end to remove header and footer
    $public_profile_enabled = true;
    $public_profile_controller = "dashboard";
    $public_profile_action = "view";
    
    // Default feed viewer: "vis/auto?feedid=" or "graph/" - requires module https://github.com/emoncms/graph
    $feedviewpath = "vis/auto?feedid=";


//6 #### Other settings
    // Log file configuration
    $log_enabled = true;
    // On windows or shared hosting you will likely need to specify a different logfile directory
    $log_filename = '/var/log/emoncms.log';
    // Log Level: 1=INFO, 2=WARN, 3=ERROR
    $log_level = 2;

    // If installed on Emonpi, allow admin menu tools
    $allow_emonpi_admin = true;

    //experimental feature for virtual feeds average, default is true, set to false to activate average agregation with all data points, will be slower
    $data_sampling = false;

    // Show all fatal PHP errors
    $display_errors = true;

    // CSV export options for the number of decimal_places, decimal_place_separator and field_separator
    // The thousands separator is not used (specified as "nothing")
    // NOTE: don't make $csv_decimal_place_separator == $csv_field_separator
    // Adjust as appropriate for your location
    // number of decimal places
    $csv_decimal_places = 2;

    // decimal place separator
    $csv_decimal_place_separator = ".";

    // field separator
    $csv_field_separator = ",";
	
    // set true on docker installations
    $allow_config_env_vars = false;

    // Dont change - developer updates this when the config format changes
    $config_file_version = "9";

I don’t think you can login using the cms, (because it is trying to use the http platform which is broken). I need to ssh through a terminal and then get to the command line on the pi. Using Linux, this is very easy, but if you have a windows system then I think it is through putty?. Once into the pi, just cd to the /var/www/emoncms directory which is where these files are.

Absolutely right! I contacted Glyn Hudson and he sent me the following, which sorted everything out–

[The] recent update required an update to emoncms settings.php file. This file is located in /var/www/emoncms/settings.php, the update script looks to see if there are any user changes to the settings file and if not the settings.php can safely be updated with default.emonpi.settings.php.

What I think has happened in your case is easier you had made a customisation to settings.php or your are running an old version of emonSD.

This fix this, you will need to connect via SSH and manually update the settings file (creating a backup first):

$ rpi-rw
$ cp /var/www/emoncms/settings.php /var/www/emoncms/backup.settings.php
$ cp /var/www/emoncms/default.emonpi.settings.php /var/www/emoncms/settings.php
$ rpi-ro
Emoncms should now load up.

To connect via SSH, see: https://guide.openenergymonitor.org/technical/credentials/#ssh

thanks yes this sorted my problem, and if it helps others Putty is a good tool to SSH and the Username is ‘pi’ and pass ‘emonpi2016’

I had the same problem with my emonpi, updated it 2 days ago and then could not access it.
I followed instructions above from mark & Glyn and now OK.
I know how to use Putty now as well!
Thanks guys

Hello,
I am having a similar problem here. Just that instead of using a pi, I am using a wamp server on windows. How can I execute this on windows? I

See Wamp Server installation [added by Moderator - RW]