Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Rebuild _config.php


Go to End


6 Posts   3217 Views

Avatar
BigChris

Community Member, 63 Posts

7 August 2009 at 12:06am

Hello,

I am new to SilverStripe and like it so far.

On a live website, I (accidentally) overwrote the site/_config.php file and the website no longer works properly.
Website is here http://www.cleanco-ltd.co.uk/

How do I rebuild/replace the _config.php file?
(This is the main site one that is located in the root directory.)

Needless to say I feel a total clown, and now require help.

Regards
Chris

Avatar
BigChris

Community Member, 63 Posts

7 August 2009 at 1:19am

Oops. Panicking I rushed into to post early.

Got it fixed. The _config.php file was not overwritten as it was in the /mysite/ directory.
It was something else that was wrong and now sorted.

Chris

Avatar
ThereBeDragonsHere

Community Member, 8 Posts

20 July 2010 at 4:01pm

I actually did make this mistake and was wondering if anyone knew the answer to this. I copied and pasted a sample _config.php and my site went from redirect loop to website error. Still not functional, but better than previously. I have tried dev/build but I'm just getting the error screen over and over again. Here is what my config file looks like now:

<?php

global $project;
$project = 'mysite';

global $databaseConfig;
$databaseConfig = array(
"type" => "MySQLDatabase",
"server" => "localhost",
"username" => "root",
"password" => "root",
"database" => "SS_mysite",
);

MySQLDatabase::set_connection_charset('utf8');

// enable nested URLs for this site (e.g. page/sub-page/)
SiteTree::enable_nested_urls();

// This line set's the current theme. More themes can be
// downloaded from http://www.silverstripe.org/themes/
SSViewer::set_theme('cunardclassic');

?>

What needs to be fixed? Thanks.

Avatar
TotalNet

Community Member, 181 Posts

20 July 2010 at 7:21pm

What do you mean by "website error" exactly?

step 1. add

Director::set_environment_type('dev');

This will give you more meaningful errors.

step 2. change the theme to blackcandy to rule out errors in your theme.

step 3. if you've changed it, go back to the default Page.php

If it's still not working, you should at least have some more detailed errors ;)

Rich

Avatar
ThereBeDragonsHere

Community Member, 8 Posts

24 July 2010 at 2:37pm

Ok, I added the set environment and now this is what I get:

====

[Warning] mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES)
GET /silverstripe/Page.php

Line 57 in /home/cnwcentr/public_html/ren/silverstripe/sapphire/core/model/MySQLDatabase.php

Source

48 * Connect to a MySQL database.
49 * @param array $parameters An map of parameters, which should include:
50 * - server: The server, eg, localhost
51 * - username: The username to log on with
52 * - password: The password to log on with
53 * - database: The database to connect to
54 * - timezone: (optional) the timezone offset, eg: +12:00 for NZ time
55 */
56 public function __construct($parameters) {
57 $this->dbConn = mysql_connect($parameters['server'], $parameters['username'], $parameters['password']);
58
59 if(self::$connection_charset) {
60 $this->query("SET CHARACTER SET '" . self::$connection_charset . "'");
61 $this->query("SET NAMES '" . self::$connection_charset . "'");
62 }
63
Trace

mysql_connect(localhost,root,root)
Line 57 of MySQLDatabase.php
MySQLDatabase->__construct(Array)
Line 94 of DB.php
DB::connect(Array)
Line 121 of main.php

====

Since I'm new to php and css, unfortunately I don't know what any of this means. But does this give people a better idea of what I should be doing to get the site to work normally again?

Avatar
TotalNet

Community Member, 181 Posts

24 July 2010 at 3:04pm

That's telling you the user for connecting to the database is wrong. It's a default MySQL setting that user "root" is disabled. Try another database user for the connection as it's unlikely you used "root" when you set up SilverStripe.

To do this, change "username" => "root" replacing "root" with the database user and of course the corresponding password replaces "root" in "password" => "root"