PDA

View Full Version : What is the dummy's way to work on Wordpress locally (w/versioning) & migrate changes


Solari
02-23-2012, 10:01 AM
(Posted this on stackoverflow.com but thought I'd also see if anyone has insights here...)

I've prowled all over the place and see a wide variety of suggestions, enough so that I'm quite flummoxed or just overwhelmed, so I'm hoping some gentle gurus can help this young jedi out...

The gist of it is, I need to be able to work on and tinker around with Wordpress on my local computer. This includes plugin updates, template modifications, and whatever else one does when they're up to their sleeves in WP (multisite). Then I need to be able to deploy those changes to our live site, which may have had additional stories, comments, etc. posted in the interim.

I will also have a couple other folks working with me on this in other locations, so obviously we will need some sort of distributed versioning (Git? Beanstalk? Mercurial? SVN out due to no distributed model) to track and update all these changes and updates.

One of my major hitches is the databases -- what's the best and easiest way to make sure the databases stay synched up? Since the site will be live, what's the best way to handle comments and stories that have been posted while the local site was being updated? This is where I've been pulling my hair out trying to figure this one out. I want to avoid having to go the route of database dumps & uploading changes if necessary plus it also wipes out any changes on live site in interim.

Where I am stuck is I am not quite knowledgeable enough to execute some complicated maneuvers to do what I want to do, so I'm hoping you can provide some sort of Dummy's Guide to do it the Dummy's way if possible that's the easiest and simplest way, if there is such a thing in today's world. ;)

For example, I have looked at using Git with Beanstalk, it seems relatively simple, but it doesn't handle databases.

Bottom line, I'm just looking for a way to make this all happen and as easily as possible with a minimum of fuss for my poor, overloaded brain.

Many humble thanks, Ray

orangeblueorangeblue
02-23-2012, 10:17 AM
Pretty simple, really.

The database is just a simple config line ... correct me if I'm wrong, but you want to be able to work with live data, but using a copy of WP you can modify at will locally, without fear of something breaking?

If so, you simply need to enable a remote connection to the live MySQL. But the cart's before the horse, here ...

Step 1: Locate a central repository machine. This is for SVN, which is probably the simplest way to let people share files / version control. This can be done for Windows, although I've only ever done it on Linux. Here is a walkthrough (http://www.codinghorror.com/blog/2008/04/setting-up-subversion-on-windows.html) for Windows. For various Linux packages, it's a simple matter of [your package installer] install subversion

Step 2: Set up a repository. In this case it's going to be your wordpress repository, so you can just name it as warranted. You can also see in the link above just how to do this as well as how to add users.

Step 3: Configure a Web server. This can either be done on the repository machine or on all of your individual machines. You will just need PHP & Apache, so any LAMP/WAMP server will do. While you won't need MySQL, you will need the MySQL extension for PHP.

Step 4: Install a SVN client for all users. You don't need anything for Linux, you can use TortoiseSVN (http://tortoisesvn.net/) for Windows. The latter will let you map a folder to a repository, which is incredibly convenient.

Step 5: Add all of the Wordpress files to the repository.

Step 6: At this point, depending on your move in Step 3, you will need to configure Apache to look in the proper directory to serve pages on localhost. This basically involves 2 substeps:

-- A. configuring your hosts file to look for a nonexistent domain, ala testdev.gatorcountry.com
-- B. modifying apache.conf or httpd.conf to define where it should look for the site testdev.gatorcountry.com

Step 7: Here you should be able to get to testdev.gatorcountry.com and modify files. Wordpress will want to know where your MySQL stuff is located. Here's where you'll add in your remote MySQL credentials and location. For example: host: www.gatorcountry.com, user: whatever, pass: whatever. This may fail. If it fails, it's likely because MySQL has not been set up for remote connections. You can address this using these instructions (http://www.thegeekstuff.com/2010/08/allow-mysql-client-connection/).

If you do all of that, you will have a local environment with version control using live data that you can modify at will. Of course, any modifications to data will be reflected on the live site, but the WP installation is now free for experimentation.

orangeblueorangeblue
02-23-2012, 10:18 AM
... Forgot to mention, SVN is not out based on your requirements. I use SVN with people all over the country without an issue.

I also may have misinterpreted your note on MySQL and wanting live data. If you do NOT want the live data but want a snapshot, you need a MySQL dump slave. This is obviously a bit more complex, even moreso than a simple MySQL RO slave.

Solari
02-24-2012, 11:34 AM
OB, good stuff. The big issue is the databases - need to be able to synch them up somehow, don't want live access in case something gets screwed up in development environment. That's really the trickiest issue here..

Ray

orangeblueorangeblue
02-24-2012, 11:45 AM
Also not insurmountable. What you're talking about is cron mysql dumps. I assume you don't need it synced much more than say every 30 minutes as this is for dev?

You can simply write a script that does the following:

1. Runs the mysqldump command to get a copy of the db
2. Commits that to the respository

You put that on a cron every 30 minutes, point your local db to the repository and you have a fresh copy of the DB every 30 minutes (assuming it can be done in that time via network). Also worth considering your transfer costs if they exist.

Alternately ...

Just create a new DB user that only has SELECT rights to prevent any data from being modified.

ThomasGoldkamp
02-24-2012, 01:30 PM
Creating a new user is probably easiest. You should be able to create one that call pull data but not modify it, correct. I also like the cron idea, that would allow us to basically stay up to sync, then whenever site was ready to switch over, we could just do it late at night knowing we'd wait for an hour or so to update anything until switch was made.

Solari
02-24-2012, 01:52 PM
How does this address times when you need to work on things over the course of several days? I.e. dumping the data to local, working on it and the site, and then you need to push the approved changes out but there will be several days of new stories and comments, etc in the interim on the live site?

There's also the matter of new users that come into the system during that time (customers), etc. as new subscribers, registrations.

Template changes, etc. will be easy but stuff that massages the database will be more hairy, even as simple as plugin updates/additions/removals due to the nature of db changes they make, just wish there was an easy way to update database automatically in portions without needing to synch the whole thing and leave posts, comments, users, etc. alone.

Keep your suggestions coming guys, it's helpful!

Thanks :)
Ray

Solari
02-24-2012, 02:07 PM
... Forgot to mention, SVN is not out based on your requirements. I use SVN with people all over the country without an issue.

Everything I read up on Subversion indicates it is not a distributed model so I'm a little confused about that unless there's been changes to it recently that allows this?

Ray

orangeblueorangeblue
02-24-2012, 03:14 PM
Everything I read up on Subversion indicates it is not a distributed model so I'm a little confused about that unless there's been changes to it recently that allows this?

Ray

Maybe you should describe what you mean by distributed. In your post you said you needed people from various locations to be able to use that. SVN supports this, in fact, remote network connections are pretty much a requirement for any version control system. Did you mean something else?

How does this address times when you need to work on things over the course of several days? I.e. dumping the data to local, working on it and the site, and then you need to push the approved changes out but there will be several days of new stories and comments, etc in the interim on the live site?

Sort of hard to answer without knowing actual use cases. If you're going to be making database changes, obviously a user with only SELECT rights won't work. Because most relational databases attempt to be atomic, there's no safe way of merging two databases.

If the use case is making server side / code changes, the answer is SELECT-only user rights.

If you need to make changes to accomplish that goal but it's not necessary that you retain those database changes, a simple mysqldump method should suffice.

But if you need to commit database changes at a later date, things become complicated. There are lot of tools (http://www.quest.com/toad-for-mysql/) for attempting to merge data, but tread lightly and make a backup first.

Solari
03-16-2012, 01:53 PM
Whoops, forgot to update yawl here. I ended up just going with my own local copy and updating things as I go on my own, realized sometimes it's best to KISS rather than get bogged down.

Ray

orangeblueorangeblue
03-17-2012, 05:39 PM
Turn in your Aspiring Nerd card, please.