Moving a site from Windows to Linux

Permalink
Anyone got any good tips on debugging Concrete5 installations?

I'm getting the dreaded "Unable to connect to database" error here:

173.254.59.230/~ctvccouk/

The background:

1. First and foremost, this site is already working on a Windows server and I am trying to get it working on this server, which is Linux

2. Yes, the server hostname, db name, db username and password are all correct and yes, the db user has full permissions on the db.

3. Yes, all the permissions on files and folders are CHMODded correctly

4. Yes, I know that Linux uses CamelCase and I have updated all the tablenames as described by sabumnim here:http://www.concrete5.org/community/forums/installation/exporting-fr...

Beyond this I'm a bit stumped. Should I give up and reinstall? Or will that still be a world of pain!?

siteadvice
View Replies: View Best Answer
jero replied on at Permalink Reply
jero
Try uploading this PHP into a file, say test.php which should be in your root:

<?php
error_reporting(E_ALL);
header('Content-type: text/plain');
require('config/site.php');
$mysqli = new mysqli(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);
echo 'Error: '.$mysqli->connect_error.PHP_EOL;
echo 'Errno: '.$mysqli->connect_errno.PHP_EOL;
var_dump($mysqli);


If your connection is OK, error and errno will be empty, otherwise you're going to see exactly what the mysql error is
siteadvice replied on at Permalink Reply
siteadvice
Hi jero

Thanks for the code snippet.

Inevitably, you can't give me something like that without me coming straight back to you with the result! Sorry!

This is the output from that code:

Error:
Errno: 0
object(mysqli)#1 (0) {
}

Sadly, I am none the wiser. What does it mean? I'd really appreciate any help, even if it's just "contact tech support". At the moment, I don't know if it's an error that warrants tech support because I don't know if I'm the one who has set the site up wrongly.
jero replied on at Permalink Reply
jero
Intriguing. I would have expected:

Error: 
Errno: 0
object(mysqli)#1 (17) { ["affected_rows"]=> int(0) ["client_info"]=> string(6) "5.1.63" ["client_version"]=> int(50163) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> int(0) ["error"]=> string(0) "" ["field_count"]=> int(0) ["host_info"]=> string(25) "Localhost via UNIX socket" ["info"]=> NULL ["insert_id"]=> int(0) ["server_info"]=> string(23) "5.1.63-0ubuntu0.10.04.1" ["server_version"]=> int(50163) ["sqlstate"]=> string(5) "00000" ["protocol_version"]=> int(10) ["thread_id"]=> int(18819) ["warning_count"]=> int(0) }


so although you have no error you don't appear to have the correct object.

What happens if you use "BROKEN" instead of "DB_SERVER"? You should see error messages for sure.
jasteele12 replied on at Permalink Reply
jasteele12
Unfortunately (and confusingly) mysqli is not used, but in config/base.php:
define('DB_TYPE', 'mysql');


Some quick testing shows mysqli to be faster (and mysql will be deprecated in the next PHP version), but there are some errors thrown that don't happen with the mysql driver.

Just thought I'd throw that out there, maybe changing that in the code above gives a different error?
jero replied on at Permalink Reply
jero
Sure, but I don't really care about that, the whole point of the exercise was to establish whether the DB credentials were good.

THe same logic holds for mysql though

<?php
error_reporting(E_ALL);
header('Content-type: text/plain');
require('config/site.php');
$link = mysql_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD);
echo 'Error: '.mysql_error().PHP_EOL;
echo 'Errno: '.mysql_errno().PHP_EOL;
var_dump($link);
mysql_select_db(DB_DATABASE,$link);
echo 'Error: '.mysql_error().PHP_EOL;
echo 'Errno: '.mysql_errno().PHP_EOL;
$sql = 'select * from Users';
$res = mysql_query($sql,$link);
var_dump($res);
echo 'Error: '.mysql_error().PHP_EOL;
siteadvice replied on at Permalink Reply
siteadvice
Well, this is embarrassing.

The code you gave me made it very apparent that as much as I thought I had the correct server name, I actually didn't, because I'd uploaded the wrong config file.

So, many thanks for a useful bit of code that immediately revealed the problem.

However, I do still seem to be having trouble.

Having corrected the config file, when I go to...

http://173.254.59.230/~ctvccouk/...

...the browser immediately redirects me to the non-existent:

http://173.254.59.230/~ctvccouk/~ctvccouk/...

Any ideas where I should look for a solution to this problem?
jero replied on at Permalink Reply
jero
I'd check your config/site.php - make sure if the constant DIR_REL is defined, that it reflects the URL you're using - in this case it ought to be ~ctvccouk

Also check what's going in in your .htaccess file
siteadvice replied on at Permalink Reply
siteadvice
Thanks again jero.

DIR_REL is blank:

define('DIR_REL', '');

Putting ~ctvccouk in there doesn't help.

The addresshttp://173.254.59.230/~ctvccouk/... is in fact a root path - 173.254.59.230 is a shared server and ~ctvccouk is the public_html folder for the account, so I think a blank DIR_REL is correct, don't you?

The .htaccess file is completely blank right now.

Any other thoughts?!
jero replied on at Permalink Reply
jero
On the contrary, DIR_REL should reflect the path part of the url, in this case /~ctvccouk

Here's what I get when I use wget to retrieve your url:

wget http://173.254.59.230/~ctvccouk/
--20:48:53--  http://173.254.59.230/~ctvccouk/
           => `index.html'
Connecting to 173.254.59.230:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location:http://173.254.59.230/~ctvccouk//~ctvccouk/... [following]
--20:48:53-- http://173.254.59.230/~ctvccouk//~ctvccouk/...
           => `index.html'
Reusing existing connection to 173.254.59.230:80.
HTTP request sent, awaiting response... 404 Not Found
20:48:54 ERROR 404: Not Found.


Something is sending a redirect. This can come from one of three places (that I can think of) 1) The index.php file/c5 installation 2) .htaccess 3) server config.

What happens if you rename/remove index.php? I would expect either a directory listing, or a 403 denied if auto indexing is off. If your statement that .htaccess is blank is true, then this leaves your webserver configuration as the only way that the redirect can be happening.
siteadvice replied on at Permalink Reply
siteadvice
Thanks for the info and suggestions.

You have been very helpful - it's so good to have someone out there to bounce problems off.

Yes, removing index.php is giving me a directory listing.

.htaccess is definitely blank

Is the server problem something you think I might be able to find in cPanel or is this most likely something I need to ask my tech support about?
citytech2 replied on at Permalink Reply
citytech2
Check your Pretty URL & BASE_PATH. I think you have written the things wrongly. Disable your pretty URL & check whether it works or not. The another possibility is 301 Redirect. Do you have any 301 redirect?

Citytech
siteadvice replied on at Permalink Reply
siteadvice
Thanks citytech

BASE_PATH is set to

http://173.254.59.230/~ctvccouk/...

I'm pretty sure this is right as this would be the root of the site.

Incidentally, I tried changing it to http://173.254.59.230/ just to see what happens (science in action!) and it just gets into an infinite loop and dies at...

http://173.254.59.230/////////////////////~ctvccouk/...

...and Firefox gives the error:

"Firefox has detected that the server is redirecting the request for this address in a way that will never complete"

I don't know how to change the pretty URL settings without the site actually running. Obviously there's no dashboard (or anything else) right now.
jero replied on at Permalink Best Answer Reply
jero
Rather than BASE_PATH, I think you mean BASE_URL. This should be your domain or IP address, it shouldn't have a path component, since that will get added on later, and as you've spotted, it goes bananas.

Try setting BASE_PATH tohttp://173.254.59.230 **no trailing /**

and set DIR_REL to "/~ctvccouk"
siteadvice replied on at Permalink Reply
siteadvice
Yep, that's fixed it.

I've set the BASE_URL to the IP address with no trailing slash and I've set DIR_REL to the subfolder, prefixed with a slash.

Perfect - I am so very grateful!

One last question, if I may beg your indulgence:

When the domain gets transferred in, am I still going to need the value in DIR_REL? If so, that's fundamentally different to all the Windows installs I've done - that value has always been blank in site.php.
jero replied on at Permalink Reply
jero
You only need DIR_REL if you're installing into a subfolder. If you're using just a domain, e.g.http://www.example.com, then DIR_REL should be defined as an empty string ''