Codeigniter应用程序安装程序

I am building a web application using Codeigniter, which will be running on localhost. I am using CI Installer as the app installer. I try modified the code it so it could also change base.url() on config.php. but, the result always

The database configuration file could not be written, please chmod application/config/database.php file to 777

and empty config.php and database.php. can someone lend a help?

my-modified-code :

core_class.php

<?php class Core {

// Function to validate the post data
function validate_post($data)
{
    /* Validating the hostname, the database name and the username. The password is optional. */
    return !empty($data['hostname']) && !empty($data['username']) && !empty($data['database']);
}

// Function to show an error
function show_message($type,$message) {
    return $message;
}

// Function to write the config file
function write_config($data) {

    // Database path
    $dbtemplate_path    = 'config/database.php';
    $dboutput_path  = '../application/config/database.php';

    // Config path
    $configtemplate_path    = 'config/config.php';
    $configoutput_path  = '../application/config/config.php';

    // Open the file
    $database_file = file_get_contents($dbtemplate_path);
    $config_file = file_get_contents($conftemp_path);

    $db  = str_replace("%hostname%",$data['hostname'],$db_file);
    $db  = str_replace("%username%",$data['username'],$db);
    $db  = str_replace("%password%",$data['password'],$db);
    $db  = str_replace("%database%",$data['database'],$db);

    $conf  = str_replace("%baseurl%",$data['baseurl'],$conf_file);

    // Write the new config file
    $database = fopen($dboutput_path,'w+');
    $config = fopen($configoutput_path,'w+');

    // Chmod the file, in case the user forgot
    @chmod($dboutput_path,0777);
    @chmod($configoutput_path,0777);

    // Verify file permissions
    if(is_writable($dboutput_path)) {
        if(is_writable($configoutput_path)) {
            // Write the file
            if(fwrite($database,$db)) {
                if (fwrite($config, $conf)) {
                    return true;
                }else{
                    return true;
                }
            }else{
                return false;
            }
        }
    }else{
        return false;
    }
}

}

The database configuration file could not be written, please chmod application/config> /database.php file to 777

Means that the database.php file cannot be modified because of a rights problem.

To fix this, you need to do as the statement says "please chmod application/config/database.php file to 777"

So find this file in your Terminal and do:

sudo chmod 777 application/config/database.php