Cotonti / Open Source PHP Content Management FrameworkContent Management Framework

Forums / Cotonti / Support / Quick Q about live and localhost

Kingsley
#1 2012-11-16 19:48


Donator
Thanked: 7 times

Were there recently changes which influences the way a localhost and a live site works?

Since a while I am not able to copy a localhost to live, or vice versa, without one or the other giving hell with logging in, with foreach errors, with tpls, with the markitup or ckeditor totally not functioning, etc

It really is driving me nuts. Now I know I am on the bottom of the foodchain when it comes to programming, But Ever since Trust showed me how to copy stuff the correct way (like db and all) I never had any problems, up to 2 or 3 months ago.

The latest thing Trustmaster showed I already tried (Click for topic). That was the last time a copy from live to local went correctly. Now it goes south either way :(

Does any one has a spare light to shine on this? :P thx

Trustmaster
#2 2012-11-16 20:04


Administrators
Thanked: 231 times

Could you describe your workflow step-by-step, how you copy things over and what you do?

E.g. that trick I showed you is quite rare, normally it is only needed when your site moves to another domain. Once set, cookie domain stays unchanged.

I think the most important rule for live deployment is this: don't copy database and cache files (or better entire datas folder) from localhost to production server. 

May the Source be with you!
Kingsley
#3 2012-11-16 20:31


Donator
Thanked: 7 times

1. copy files (yes, included the whole datas file)

2. copy db (included add droptable)

3.insert db into localhost

4. remove cached files

5. edit config.php

6. the login error check -> if error apply your fix

This is the way you told me to do it back in the day, when I switched from Genoa to Siena. Always worked perfectly (datas folder included) up till the above.
I will try now without copying the complete datas folder. One question about that though; I always put things like pageavatar and page multi avatar (for gallery and such) folders in there too, can those cause a problem? Should they be on a different spot?

when I design for an existing site, I always copy the live site to my localhost and then adjust the skin accordingly. New site I completely develop on localhost and then manually copy all the data into the new live site. But most work I do is on exsisting sites, so yeah, I often need to copy stuff to my localhost. I know this probably makes some (professional) programmers choke on their coffee or sandwich, but it's a way i feel comfortable with, and at the same time gives me a good look on the site and its content (images and such).

If you have suggestions for me to change, I am willing :)


This post was edited by Kingsley (2012-11-16 20:37, 2 years ago)
Trustmaster
#4 2012-11-16 21:46


Administrators
Thanked: 231 times

That's quite a tedious path you follow every time :) It might be fine for a one-off action like Genoa2Siena migration, but there's no need to do it with regular updates.

First, let's repeat the rule #1: don't copy entire database and datas from localhost to production, it breaks things. Apart from that login issue, you loose all the data that has been added by users on the production site from the period you made a dump of it for your localhost.

Then, let's make it clear that there are different kinds of updates that you make to the production site:

  1. Cotonti updates, 0.9.10 => 0.9.11, 0.9.11 => 0.9.12, etc.
  2. Theme updates, editing tpl/css/js files, adding pngs, etc.
  3. Extension updates. Installing new plugins, modifying tpls for them, testing data.
  4. Content updates. Adding new content on site like pages, forum sections, etc.

Now comes the rule #2: these kinds are handled differently.

Cotonti updates

These are described here. Shortly, after downloading another cotonti update, just overwrite the old files and run install.php to update the database. I apply the same procedure to localhost first and if it is fine, I apply the same procedure to the production site (without copying stuff to localhost and back again).

Theme updates

Edit and test on localhost, then upload to production.

Extension updates

This gonna be the trickiest part. If you add new functions to your site and want to make them work on localhost first, then:

  1. Yes, copy files and data from your production site to localhost if you feel that it is necessary to test stuff. But don't copy these: datas/config.php, datas/cache, and some MySQL tables such as cot_config and cot_cache. In most cases this step is optional, I don't do it more often that once a few months.
  2. Install plugins, modify tpls, enter test data on localhost. Remember what files you modify and how you enter the data, but all you do here is mostly a draft.
  3. Copy the new/updated files in modules, plugins and themes folders to production site.
  4. Don't copy the database or datas! After uploading the files, you have to install plugins on the production site and enter the data if necessary via forms. But it doesn't break anything or loose data users submitted while you experimented on step 2.

This is it.

Content updates

OK, here comes the rule #3: don't use localhost to update production site's contents. Really, use localhost to play with extensions and templates, but contents should be edited on the production site directly. Use Drafts, Validation queue and Permissions to hide stuff from visitors' eyes unless you want them to see it.

Ah, and the rule #4: make backups of the production site from times to times. Just in case it all goes absolutely wrong one day.

May the Source be with you!
Kingsley
#5 2012-11-18 00:33


Donator
Thanked: 7 times

Your list is quite longer than mine :P but I see what your pointing at.

I never use my localhost to update production sites, I do however, dl the production site to use it on my localhost while I create/adjust the theme (saved me the time to create a local db with all kinds of content, the easy way out, I know..). The only times I did do localhost to production is when it is a completely new site. Yeah I know.. it was the easy option.. Saved me the time of manually copying page/forum structures and whatnot from local to production. But if that breaks things now, I will quit doing that :)

Well, your post is now in my cotonti folder for future reverence, so thank you for your elaborate answers. Cheers!

Trustmaster
#6 2012-11-18 06:16


Administrators
Thanked: 231 times

#36268 Kingsley: 

I never use my localhost to update production sites, I do however, dl the production site to use it on my localhost while I create/adjust the theme (saved me the time to create a local db with all kinds of content, the easy way out, I know..). The only times I did do localhost to production is when it is a completely new site. Yeah I know.. it was the easy option.. Saved me the time of manually copying page/forum structures and whatnot from local to production. But if that breaks things now, I will quit doing that :)

You're right, moving from localhost to production for the 1st time sounds reasonable too. But you have to fix config.php, cookiedomain/cookiepath in cot_config and clear cache (both in datas/cache and cot_cache table) for your production site to start working correctly. I think this can be added as a 5th case above.

May the Source be with you!
Kingsley
#7 2012-11-18 15:12


Donator
Thanked: 7 times

As said, I will follow this path now..