1 of 2
1
How to keep an offline version of my site
Posted: 15 February 2008 06:31 PM   [ Ignore ]  
Grad Student
Avatar
Rank
Total Posts:  98
Joined  06-22-2007

Ok, what I want to do is to have a complete copy of my online site on my PC so that I could experiment and develop new features. Also maybe later redesign the whole site.
What is the safest method to accomplish it and not to destroy my online version when I’m going to overwrite the enhanced offline version.

Profile
 
 
Posted: 16 February 2008 01:27 AM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  406
Joined  09-09-2006

You’ll want to set up a local server. If you are on Windows a lot of people use XAMP. This will install Apache, PHP and MySQL locally - all the things you need to run ExpressionEngine. There’s some documentation on the site that should help you to set up a site.

Then FTP your EE site files to your local machine. Take a copy of your MySQL database from your live server and then add it to your local machine. Your paths will be different locally so be sure to fix those.

It is a little tricky but once you’ve done it once its no problem.

 Signature 

Shape Shed | Usable, elegant web design, London, UK
Twitter | Flickr | LastFm | Blog | EE addons

Profile
 
 
Posted: 16 February 2008 08:43 AM   [ Ignore ]   [ # 2 ]  
Grad Student
Avatar
Rank
Total Posts:  98
Joined  06-22-2007

Yes that is the process I know, I use WAMP instead of XAMP smile
The thing that is most problematic to me is how, - in what way - to export the database from the online site and how to import properly on my local server. Do I need to export as I file? In the export file as I see the query first creates the database, then creates the tables and fills them with content. So do I first need to import the database and then install the EE on my local server or the other way!
Sorry but I’m confused a little, just someone please tell me the process in details.

Profile
 
 
Posted: 16 February 2008 12:16 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  368
Joined  11-05-2002

Not familiar with windows….

but with Unix, macos, linux etc….

You must first make certain a “server” such as apache is running locally. That is easy enough. You must have a working copy of mysql on the server and working.

Some of this is guesswork, but it worked fine moving from server to server…..

You can tar or zip the entire web directory, which of course contains all the EE files, and then put this onto your local server. Then you can do the same with the mysql directory which contains the EE data, and move that into the local directory which holds you mysql data files

I would suggest using phpmyadmin on your local server so you can easily “see” these files. After such a move, you may have to run a “repair or optimize” move through phpmyadmin or else change some permissions, but it should be fairly evident what any problems are.

So you need not export your mysql, just zip or tar it and move it to the right place….hopefully!

OH, you will have to change the EE settings to reflect the paths, etc of your local machine. It may respond to locahost or you can use the IP if you have a static one - even a static internal network IP.

 Signature 

Craig Issod, Publisher
Hearth.com - Answers to all your Burning Questions
http://www.hearth.com

Profile
 
 
Posted: 16 February 2008 03:22 PM   [ Ignore ]   [ # 4 ]  
Grad Student
Avatar
Rank
Total Posts:  98
Joined  06-22-2007

You can tar or zip the entire web directory, which of course contains all the EE files, and then put this onto your local server.

Ok I did it, just downloaded all the files and put them on my local server

But…

Then you can do the same with the mysql directory which contains the EE data, and move that into the local directory which holds you mysql data files

Where is that mysql directory, how is it called? I was thinking about getting all the content from the tables and put on my local server, so I don’t need to export them?

Sorry, I’m complete newbie about these server issues. Maybe a best way is to hire somebody in order to safely perform these stuff. Cause in the future I plan to make a complete redesign of my site and develop new features as I learn them with the EE tags. But with already existing database I found this impossible, though I know it isn’t.

Profile
 
 
Posted: 16 February 2008 04:38 PM   [ Ignore ]   [ # 5 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  609
Joined  06-29-2005

I used MYSQLDUMPER to backup my entire database to a file, downloaded that, then restored it again using the same program on the local installation. Select all the tables EXCEPT the exp_sites table, which has info apparently local to the particular installation, and broke the local restoration of the site.

XAMMP worked great, but isn’t the perfect clone of php/mysql to windows, because I got some errors - though everything worked well enough to allow me to do the restore and use the fresh local installation of EE.

Terry

Profile
 
 
Posted: 16 February 2008 05:27 PM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  368
Joined  11-05-2002

When you install a version of mysql on your computer, it should automatically set up the proper directories where it keeps the files.

In the case of my linux distribution, the directory is:
/usr/local/mysql/var/eengine

in the usr/local/mysql/var directory is a directory for each db.

so you would unzip the eengine zip file in the var directory.

I think on windows your default directory for data may be called data….see:
http://dev.mysql.com/doc/refman/5.0/en/windows-create-option-file.html

 Signature 

Craig Issod, Publisher
Hearth.com - Answers to all your Burning Questions
http://www.hearth.com

Profile
 
 
Posted: 16 February 2008 05:40 PM   [ Ignore ]   [ # 7 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  609
Joined  06-29-2005

Like I said, if one has the exp_sites table copied along with the rest to the local computer, the installation will be broken. Might work if you copied the mysql data first and then re-installed EE. Best and easiest to do it with a selective restore.

Terry

Profile
 
 
Posted: 19 February 2008 09:47 AM   [ Ignore ]   [ # 8 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  286
Joined  02-02-2007

Hi, braveheart,

Here are the steps I go through when I want to have wholly functional copy of my website on localhost. Some steps are specific to modules, extensions and plugins I use, but you may need to perform analogous steps for add-ons you use. For setting local website I use EasyPHP 2.0 beta 1 from http://easyphp.org/index.php.

I. Local Host and ExpressionEngine preparation:


1. Install EasyPHP 2.0b1 in c:\EasyPHP\ .

2. Right-click EasyPHP quick-launch icon, go Configuration\PHP. It will open php.ini file. Make following changes in this file:
  a) max_filesize = 2000M
  b) memory_limit = 2000M
  c) post_max_size = 2000M
  d) max_execution_time = 0
 
3. Open file c:\EasyPHP\phpmyadmin\libraries\import\sql.php and type after the line “/* SQL import plugin for phpMyAdmin */” following line:
“set_time_limit(0);” .

4. Restart EasyPHP.

5. Right-click EasyPHP quick-launch icon and go Administration\phpMyAdmin. Then create database “db_name” using collation “utf8_general_ci” .

6. Copy ExpressionEngine’s files into folder c:\EasyPHP\www\ .
Then right-click EasyPHP quick-launch icon, click “Local web” and install ExpressionEngine
entering “system” as system folder and “root” as MySQL username, “db_name” as database name.

7. Go to www.expressionengine.com and download plugin “Comment HTML Formatting Buttons” and unzip it to c:\EasyPHP\www\system\plugins\ directory.
Once the plugin is copyed, you should be able to see it CP Home >  Admin >  Utilities >  Plugin Manager. Then open file c:\EasyPHP\www\system\config.php and
type the line “$conf[‘remove_close_all_button’] = ‘y’;” .

8. Go to www.expressionengine.com and download plugin “Allow EEcode” and unzip it to c:\EasyPHP\www\system\plugins\ directory.
Once the plugin is copied, you should be able to see it CP Home >  Admin >  Utilities >  Plugin Manager.

9. Go to www.expressionengine.com and download Forum module. Unzip it. Inside you will find “forum” directory; copy it to c:\EasyPHP\www\system\modules\ .
Inside you also will find “forum_themes” directory; copy it to c:\EasyPHP\www\themes\ . Inside you also will find “forum_attachments” directory;
copy it to c:\EasyPHP\www\images\ . Inside you also will find two files - lang.forum.php and lang.forum_cp.php; copy them to c:\EasyPHP\www\system\language\english\ .
Go to local website’s Control Panel, open Modules tab. You will se entry listed for the “Discussion Forum”. On the right side click “Install”; forum module will be installed.

10. Go to http://expressionengine.com/forums/viewthread/68277/ , download Edit Menu extension and unzip it to c:\EasyPHP\www\system\extensions\ directory.
Once the extension is copyed, you should be able to see it CP Home >  Admin >  Utilities >  Extension Manager. If it is not enabled, enable it.

Continued in the next post.

 Signature 

Full list of plugins here

Child Categories
Browser Sniff
Category Id
Entries List

Profile
 
 
Posted: 19 February 2008 09:59 AM   [ Ignore ]   [ # 9 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  286
Joined  02-02-2007

II. Restoration of the website on the local host:


11. Go to https://secure.enginehosting.com/controlpanel/ and log into Web-based FTP and File Manager. Go to public_html/images/uploads/ and download all images.
Then copy all images to c:\EasyPHP\www\images\uploads\ .

12. Open website’s phpMyAdmin > databases > eh5659a > export . Select “drop table”, select “Save as File” and press button “Go”. The database will be exported.

13. Open export file in text editor and delete or comment the line “CREATE DATABASE `db_name` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `db_name`;” .

14. Go localhost> phpMyAdmin > databases > eh5659a > import, select file to be imported, select Character set of the file “utf-8”,
deselect “Allow interrupt of import in case script detects it is close to time limit” and push “Go” button. Database will be imported; it may take
several minutes to complete.

15. If local website’s Control Panel looks unstyled, go to c:\EasyPHP\www\themes\ and copy folder “cp_themes” to c:\EasyPHP\www\system\ . ExpressionEngine will discover it
and Control Panel will be styled properly.

16. Log into local website’s Control Panel, go Admin >  System Preferences >  General Configuration and make sure that
  a) URL to the root directory of your site is http://127.0.0.1/
  b) URL to your Control Panel index page is http://127.0.0.1/system/index.php
  c) URL to your “themes” folder is http://127.0.0.1/themes/
  d) Theme Folder Path is C:/EasyPHP/www/themes/ [To figure out absolute path of the server, allow PHP for any template in template group preferences
  and type this code into that template <?php echo dirname ($_SERVER[SCRIPT_FILENAME]) . ‘/’; ?>]
  e) Default Language is English
  f) Default Character Set is utf-8
  g) Default XML Language is English
  h) Name of your site’s index page is index.php
 
17. Go Admin > System Preferences >  Captcha Preferences and change
  a) Server Path to Captcha Folder to C:\EasyPHP\www\images\captchas\ [To figure out absolute path of the server, allow PHP for any template in template group preferences
  and type this code into that template <?php echo dirname ($_SERVER[SCRIPT_FILENAME]) . ‘/’; ?>]
  b) Full URL to Captcha Folder http://127.0.0.1/images/captchas/
 
18. Go Admin > System Preferences > Emoticon Prefrences and change “URL to the directory containing your smileys” to http://127.0.0.1/images/smileys/ .

19. Go Admin >  Weblog Administration >  File Upload Preferences >  Edit File Upload Preferences and change
  a) Server Path to Upload Directory to C:\EasyPHP\www\images\uploads\ [To figure out absolute path of the server, allow PHP for any template in template group preferences
  and type this code into that template <?php echo dirname ($_SERVER[SCRIPT_FILENAME]) . ‘/’; ?>]
  b) URL of Upload Directory to http://127.0.0.1/images/uploads/
 
20. Go to Admin >  Weblog Administration >  Weblog Management >  Edit Weblog > Path Settings for every weblog and change Weblog URL so that the first part of it would be
http://127.0.0.1/index.php/ .

21. Go to My Account > Extras >  Quick Links and change Link URL of My Weblog into http://127.0.0.1/index.php/ .

22. Log into Control Panel of local website, go Templates > Global Variables and change variable “image_upload_folder” to “http://127.0.0.1/images/uploads/” .
Now in local webpages all images should be displayed .

The step 20 may be most tedious if you have many weblogs. I have even posted a feature suggestion in thread about how it might be avoided, but nobody seems to be interested.

 Signature 

Full list of plugins here

Child Categories
Browser Sniff
Category Id
Entries List

Profile
 
 
Posted: 22 February 2008 07:53 PM   [ Ignore ]   [ # 10 ]  
Grad Student
Avatar
Rank
Total Posts:  98
Joined  06-22-2007

Wow thanks Laisvunas, really detailed answer, I believe other folks from the forum will find this very helpful.

However I got stucked at point 16 on your second post, it seems I can’t login to my CP anymore, there is no wrong password warning just it adds “S=5305b19b32d95d8f35b8d5c3996d3654f4778253” after the usual URL
I tried correcting this config.php as I read that problem in other posts, but still can’t login after modifying the config.php

Profile
 
 
Posted: 22 February 2008 08:57 PM   [ Ignore ]   [ # 11 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  609
Joined  06-29-2005

20. Go to Admin > Weblog Administration > Weblog Management > Edit Weblog > Path Settings for every weblog and change Weblog URL so that the first part of it would be
http://127.0.0.1/index.php/ .

This may be one of the things that I fixed by not exporting the exp_sites table. All the path names seemed to work correctly in my site as long as I didn’t include that one, if I recall correctly.

[Edit - no, that was not something that got fixed afterall. I just checked on a new local copy and as mentioned above, all the weblog’s path urls have to be changed on the entire site. Seems like a nice module project!!!]

Oh, and THANK YOU, Laisvunas, for an excellent reference piece. Please make a WIKI entry of this.

Terry

Profile
 
 
Posted: 22 February 2008 09:32 PM   [ Ignore ]   [ # 12 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  609
Joined  06-29-2005

OK, you are going to love this!

Rather than visit every single weblog on your local copy of the site as described in step #20 above, go to Admin > Utilities > Find and Replace

There you will find a drop-down selector allowing you to pick what part of the database you wish to have an effect upon.

In what database field do you want the replacement to occur?

Select, at the top, Site Preferences and the name of the site you are working with.

Then enter in the box that says:

Search for this text

http://the_wrong_site_url.com/index.php

Enter into the next box that says:

And replace it with this text

http://127.0.0.1/index.php

Hit submit and it is done in a flash!

Just be careful, of course. These changes cannot be necessarily easily undone.

Terry

Profile
 
 
Posted: 23 February 2008 11:15 AM   [ Ignore ]   [ # 13 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  286
Joined  02-02-2007

@braveheart I have no idea why you got stuck on the step 16. When I go through this step everything works OK.

@tbritton Thanks very much for suggestion. It works and I am already using it.

I have posted WIKI article titled “Complete copy of the website on localhost” here. There is nothing new in it, just the steps listed in my previous posts in this thread together with the solution tbritton has proposed..

 Signature 

Full list of plugins here

Child Categories
Browser Sniff
Category Id
Entries List

Profile
 
 
Posted: 23 February 2008 12:14 PM   [ Ignore ]   [ # 14 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  609
Joined  06-29-2005

Michael Boyink also added here that the variable {site_url} can be used in those paths, and even in the file upload path. Then you need only change it in one location - the site path in System Preferences General Settings.

URL to the root directory of your site
This is the directory containing your site index file.

How nice!

Terry

PS - added categories to the Wiki article along with this bit of info from Michael. Thanks for doing the Wiki!

Profile
 
 
Posted: 24 February 2008 11:07 AM   [ Ignore ]   [ # 15 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  286
Joined  02-02-2007

@tbritton Thanks very much for improving WIKI article.

 Signature 

Full list of plugins here

Child Categories
Browser Sniff
Category Id
Entries List

Profile
 
 
Posted: 24 February 2008 11:41 AM   [ Ignore ]   [ # 16 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  609
Joined  06-29-2005

You’re welcome!

I have a question on number 12.

12. Open website’s phpMyAdmin > databases > my_database > export . Select “drop table”, select “Save as File” and press button “Go”. The database will be exported.

Why select “drop table”? Doesn’t that delete the tables???

From mysql docs page:

DROP TABLE removes one or more tables. You must have the DROP privilege for each table. All table data and the table definition are removed, so be careful with this statement!

Terry

Profile
 
 
Posted: 26 February 2008 12:56 PM   [ Ignore ]   [ # 17 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  286
Joined  02-02-2007

@tbritton In step 12 “drop table” is being selected exactly in order to delete some tables.

Why some tables should be deleted? To explain this I must to say something about difference between steps 1-10 (Phase I: Local Host and ExpressionEngine preparation) and steps 11-22 (Phase II: Restoration of the website on the local host). The difference is this. You need to go through steps of the Phase I only ONCE; to go through steps of the Phase II you should EACH TIME when you want to have complete and fully functional copy of your website on the localhost.

Selecting “drop table” is not needed if you are restoring website on localhost for the first time. But if you already have a copy of the website on localhost but your remote website was changed and you want that in local website those changes were exactly replicated, selecting “drop table” has sense. “Drop table” statements ensure that all tables of the earlier copy of the website will be deleted and old tables will be replaced by new tables. If you would try to restore database by using only “Insert” statements, some old information in tables would be retained and EE tables in local website would differ in some respects from remote ones.

The same could be achieved without “drop table”. You can use “drop database” instead. In this case step 13 is not needed. But if you use “drop database” then ALL tables of local database will be deleted, both those tables which were created by EE and those which maybe were created by you while doing on localhost some experimenting with PHP/MySQl .

So, it seemed to me that
1) in order to have exact copy of the website either “drop database” or “drop table” is needed
2) “drop table” is better suited to this task since it deletes only those tables which have counterparts in remote site and leaves other tables intact.

 Signature 

Full list of plugins here

Child Categories
Browser Sniff
Category Id
Entries List

Profile
 
 
Posted: 26 February 2008 01:23 PM   [ Ignore ]   [ # 18 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  609
Joined  06-29-2005

Ahh! Thank you very much for that insight - it is a very good observation and solution.

Terry

Profile
 
 
   
1 of 2
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65011 Total Logged-in Users: 52
Total Topics: 82079 Total Anonymous Users: 47
Total Replies: 441118 Total Guests: 310
Total Posts: 523197    
Members ( View Memberlist )