Live to Local

Discussion in 'Server Operation' started by BobJam, May 15, 2011.

  1. BobJam

    BobJam New Member

    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?
  2. falko

    falko Super Moderator ISPConfig Developer

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

    BobJam New Member

    @ 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).
    Last edited: May 16, 2011
  4. falko

    falko Super Moderator ISPConfig Developer

    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.
  5. BobJam

    BobJam New Member

    @ falko,

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

    BobJam New Member

    @ 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?
  7. BobJam

    BobJam New Member

    @ 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?
  8. falko

    falko Super Moderator ISPConfig Developer

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

    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.
  9. BobJam

    BobJam New Member

    @ 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.
  10. BobJam

    BobJam New Member

    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.
  11. BobJam

    BobJam New Member

    The next big hurdle?

    My brother-in-law, whose site it actually is . . . I just built it for him . . . . . . is now having his daughter maintain and edit the live site.

    She has a Windows machine. I'm pretty checked out now on my Linux machine (or at least I have a running start).

    So I need to learn how to do this on Windows (we do CrossLoop RA sessions, so I can install it on her machine in a CrossLoop session).

    Right now she's doing live edits on the live site (under my "supervision"). But I'd like to get her setup with a "test" site on HER machine.

    I have a Windows VM on this machine, and another dual boot machine with Windows as one of the boots. So I'm going to 'speriment on one of them.

    Am assuming the first step would be to start off with WAMP, and see if I can get her server working.

    Hopefully, I've run into the major pitfalls with this Linux install on my machine, and Windows will be a breeze.

    But I do anticipate "new" and different issues.

    Someone on another forum has suggested setting up a "test" live site (duplicate) on the host sever, and I guess that's an option too.

    Any tips or heads up on a local test site in Windows or the live site "test" duplicate option?
  12. falko

    falko Super Moderator ISPConfig Developer

Share This Page