HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (
-   Server Operation (
-   -   Live to Local (

BobJam 15th May 2011 11:20

Live to Local
I want to get a working copy of my live site onto my local machine (yes, I did it backwards . . . whereas most do it locally at first and then upload to live, I did it the other way around).

My OS is Ubuntu 9.10, and instead of LAMPP, I did a standalone install of PHP 5.2, Apache2, and MySQL Server version 5.1.37-1ubuntu5.5. So my local root is /var/www.

Apache runs just fine and so does PHP and MySQL. I transferred my live site db to my local machine and believe it or not the privileges are such that it CAN connect to the MySQL server (I got the usual "Cannot connect . . ." at first, but assigned the privileges to that db via phpmyadmin.)

In any case, now I'm sitting on my local machine with a working apache2, PHP, and MySQL, the db from the live site and not much else. Sort of like all dressed up and no place to go.

I did however FTP all my public_html folders and files to the /var/www folder. The live site is Joomla built (1.5.22), but simply transferring the folders and files and also the db to my local machine doesn't do anything but give me the standard apache welcome screen, "It works! This is the default web page for this server. The web server software is running but no content has been added, yet." For some reason the Joomla built content is missing in action.

I really don't know where to go from here. I have no idea what I have to do or even if I can do anything, like modify the configuration.php file from my live site, a copy of which now resides on /var/www.

What I'm thinking about is removing those Joomla folders and files on /var/www and just using Akeeba to backup my live site and installing kickstart.php on my local /var/www and the zipped Akeeba backup and then running kickstart. (Would I remove the apache index.htm file from /var/www, so that only the archived backup and kickstart.php reside on /var/www, and then run kickstart? Do I need to modify the permissions on the /var/www folder for kickstart to work? I DO have the Akeeba and Kickstart manuals and the Akeeba URL).

I'm really lost here . . . I need some kind of a step-by-step guide on where to go from here.

Again, the ultimate goal is to get a working copy of my live site on my local machine, so that I can 'speriment with mods and no longer risk borking the live site. Obviously, included in the scheme would be how to go from local to live when I like the mods and see that they work. Could I do that also with Akeeba?

falko 16th May 2011 13:21

Can you rename/delete /var/www/index.html and check if it works then?

BobJam 16th May 2011 19:28

Re: Live to local
@ falko,

Now I'm getting:


Warning:  include(/home/rbjamie/public_html/zbblock/zbblock.php) [function.include]: failed to open stream: No such file or directory in /var/www/index.php on line 1

Warning:  include() [function.include]:  Failed opening '/home/rbjamie/public_html/zbblock/zbblock.php' for  inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/index.php on line 1

Warning:  Cannot modify header information - headers already sent by (output started at /var/www/index.php:1) in /var/www/libraries/joomla/factory.php on line 566
Database Error: Unable to connect to the database:Could not connect to MySQL

First of all, "zbblock" is the security software I use on my LIVE site. But more importantly, I think that first "Warning" line is because the path on line one in index.php does NOT exist on my local machine. Which is why I'm thinking to try and use Akeeba because maybe it will adjust those paths.

In the alternative, I guess I could just as well go in there and edit the index.php with my IDE. But then I'd have to do that on my LIVE site everytime I uploaded my content modifications.

The second warning seems to be the same.

The third warning I'm not too sure about, except I see there's that damn " . . . could not connect to MySQL" nonsense again.

I thought I had solved that whole problem when I just flat out reset the MySQL password with the sequence:

sudo /etc/init.d/mysql stop

sudo mysqld --skip-grant-tables &

mysql -u root mysql

And then at the MySQL prompt:

And then I was using my own "testme.php" file:


 START editing here...

$mysql_host    =  'localhost';
$mysql_username =  'root';
$mysql_password =  '';
$mysql_database =  '';

 STOP editing here...

echo('<p>Trying to connect to MySQL on server <strong>'.$mysql_host.'</strong> as user <strong>'.$mysql_username.'</strong> with password <strong>'.$mysql_password.'</strong>.</p>');
if(!is_resource($db)) {
    echo('<p style="color:#c00">FAILED</p>');
    echo('<p>Debug - '.mysql_errno($db) . ':' . mysql_error($db). '</p>');
} else {
    echo('<p style="color:#0c0">SUCCESS</p>');
echo('<hr />');
mysql_query('SET CHARACTER SET \'utf8\';',$db);
mysql_query('SET NAMES \'utf8\' COLLATE \'utf8_general_ci\';',$db);
echo('<p>Trying to talk to database <strong>'.$mysql_database.'</strong>.</p>');
if(!mysql_select_db($mysql_database,$db)) {
    echo('<p style="color:#c00">FAILED</p>');
    echo('<p>Debug - '.mysql_errno($db) . ':' . mysql_error($db). '</p>');
} else {
    echo('<p style="color:#0c0">SUCCESS</p>');
    exit('<p>Thank God! Now it's time for that cigar...</p>');

to see if it worked. The indication was "Success" when I plugged in the LIVE site db name and reset password. (BTW, haven't divulged any passwords or user names here because in the php script above, the default user is "root" and the default password is nothing (""). I just plugged in the actual db name and new password.)

But I think the configuration.php file from my LIVE site, plus some other imported files, needs to be edited also. The paths are all screwed up.

Bottom line, again this was why I was thinking of using Akeeba to avoid all this hassle . . . which it advertises it will do.

Another problem is that I know just enough to be dangerous, and I was hoping maybe Akeeba would help me not to shoot myself in the foot, which I often end up doing when I try to do things myself.

I get it "half-right" and screw myself up with the other half that is absolutely wrong.

Which is another reason why I need to get my site on my local machine for edits. I've been lucky so far, but sooner or later if I keep editing the LIVE site, the law of averages is going to catch up with me and I'm going to bork the LIVE site.

Fortunately I just renamed the Apache index.htm file to "indexold.htm" and was able to recover to at least where I was getting the apache "working" message, which essentially puts me back to square one.

I've got to be missing something real simple because I know a lot of people have this kind of setup for test editing and they can't be going through the tedious cycle of resetting paths every time they go from local to live and then have to adjust the paths on live.

So what am I missing?

(BTW, thanks for taking out that spam).

falko 17th May 2011 15:02

Does your test site use the same document root than the live site? If not, you might have to adjust paths, maybe in configuration files, maybe also in the database.

BobJam 17th May 2011 19:47

Re: Live to local
@ falko,

Don't know about the DocumentRoot setting for sure in my local installation . . . where would that be? Apache2.conf?

BobJam 17th May 2011 20:00

Re: Live to local
@ falko,

There IS a DocumentRoot setting in the apache2 "000-default" file located within "/etc/apache2/sites-enabled/" on my local machine, and it's "DocumentRoot /var/www".

I assume on the live site it's "public-html".

I don't see any DocumentRoot setting in my configuration.php but I do see a line: "var $tmp_path = '/home/rbjamie/public_html/tmp';", which obviously doesn't exist on my local machine.

The httpd file on my local machine is entirely empty.

Do these settings give you any clue?

BobJam 17th May 2011 20:05

Re: Live to local
@ falko,

I have no idea if the Joomla 1.5 db stores path info. How would I find this out? Could I look at the db via phpmayadmin and tell, and which parameter would I look at? "jos_" what?

falko 18th May 2011 15:01

Can you find out the document root of the live machine (in the Apache configuration)?


Originally Posted by BobJam (Post 257076)
@ falko,

I have no idea if the Joomla 1.5 db stores path info. How would I find this out? Could I look at the db via phpmayadmin and tell, and which parameter would I look at? "jos_" what?

I'm no Joomla expert, but you could create an SQL dump of your database, open it in a text editor and search for the path.

BobJam 18th May 2011 19:36

Re: Live to local
@ falko,

On the idea of dumping the MySQL db to a text file and then searching for paths . . . my compliments, very creative, and it worked nicely.

Yes, as a matter of fact there are paths in the db, both external (URL's) and INTERNAL, which is what I'm interested in.

On the issue of DocumentRoots, my local root is var/www and the LIVE site root is public_html.

But on that issue, and also the MySQL/internal paths issue, I think I have an idea. Instead of having these paths as ABSOLUTE, which they ARE, why not edit them to be RELATIVE, so that they're based on the tree structure, which is the SAME for both LOCAL and LIVE?

For example, my php.ini file contained a path named "/home/*<my user name>*/public_html/zbblock/zbblock.php" and I changed it to "zbblock/zbblock.php" ("zbblock" is site security software I use.)

I was getting the notice that Apache couldn't find ""/home/*<my user name>*/public_html/zbblock/zbblock.php", and when I changed it to zbblock/zbblock .php" (the RELATIVE path), the warning went away.

Looks promising.

BobJam 20th May 2011 13:16

Re: Live to local
Have I solved the problem?

Yes and no. I have the live site set up on my machine now, but at first all the internal links in the menu were giving me a 404.

The solution to that was simple: disable SEF.

And then I had a permissions issue on configuration.php. Simple solution again.

The big breakthrough was ABSOLUTE paths versus RELATIVE paths. Once I made all the paths RELATIVE, things began falling in place.

It had ABSOLUTELY nothing to do with httpd or httpd-vhosts configs or any other configs for that matter. Nor did it have anything to do with the .htaccess file. I was chasing my tail on a lot of those troubleshooting efforts.

The "no" part is that I need to learn how to upload my changes. For now I'll test the changes and then hopefully do the same procedure on the live site if it works on the test site.

But ultimately I need to gain enough confidence in my "test" site so that I can just flat out upload them and not go through hoops twice.

Right now I'm afraid that if I uploaded the test site db I'd bork the live site.

All times are GMT +2. The time now is 09:02.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.