Я создаю веб-приложение с использованием Codeigniter, которое будет работать на localhost. я использую Установщик CI как установщик приложения. Я пытаюсь изменить его код, чтобы он также мог изменить base.url () на config.php. но результат всегда
Файл конфигурации базы данных не может быть записан, пожалуйста, chmod
файл application / config / database.php до 777
и пустые config.php и database.php. может кто-нибудь помочь?
мой модифицированный код:
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;
}
}
}
Не удалось записать файл конфигурации базы данных, пожалуйста, выполните команду chmod application / config> /database.php в 777
Означает, что файл database.php не может быть изменен из-за проблем с правами.
Чтобы это исправить, нужно сделать так, как говорится в заявлениипожалуйста, выполните команду chmod application / config / database.php в 777«
Так что найдите этот файл в вашем терминале и выполните:
sudo chmod 777 application/config/database.php
Других решений пока нет …