Jump to content


Photo

Migrating ProcessWire from localhost to web host

migration moving

  • Please log in to reply
6 replies to this topic

#1 tinacious

tinacious

    Full Member

  • Members
  • PipPipPip
  • 66 posts
  • 33

  • LocationToronto, Canada

Posted 18 March 2012 - 12:38 PM

Hello everyone!

I'm just about finished developing my site on my localhost (MAMP) with ProcessWire and I'm wondering what I need to do to migrate my site off my local server onto my hosted server. I want to make sure I know all the steps before I start in case I miss something.

The database name has changed as the server automatically names databases and users—they differ from ones I've originally created—so I'll need to change any instances of the database name and user. I'm guessing I modify the config.php file to match the new credentials. Is that it? Are there anymore instances I need to worry about, e.g. in the SQL file?

Other than modifying the config.php file, re-uploading all the files and importing the SQL file, is there anything that I'm missing?

From what I've read in other posts, it seems that migrating ProcessWire should be easier than WordPress. I just wanted to confirm steps before I start in case I run into problems later on for doing it wrong now.

Thank you for your help!

Tina

#2 formmailer

formmailer

    Sr. Member

  • Members
  • PipPipPipPip
  • 245 posts
  • 29

  • LocationHudiksvall, Sweden (but originally from The Netherlands)

Posted 18 March 2012 - 01:00 PM

Hi Tina,

Your steps cover most of the process.
A few notes:
  • Make sure that the files/folders in the assets folder are writable
  • Make sure to copy the the .htaccess file to the root of your website (some FTP programs hide this file by default)
  • I prefer to delete the contents of the /site/assets/cache folder, but I am not sure if it's needed. You can do this before uploading the site, just to safe time.
  • If you are going to use a new sql database, you can change the name and the user in the site/config.php file.
    For future use, for example if you want to copy the production database to your local mamp installation, make sure you add "drop tables" to your export, otherwise you will get errors about existing tables.
That's all I can think of now. And if something should go wrong.... these forums are here to help you. 8)

/Jasper

#3 Michael Murphy

Michael Murphy

    Distinguished Member

  • Members
  • PipPipPip
  • 95 posts
  • 53

  • LocationBasel, Switzerland

Posted 18 March 2012 - 03:45 PM

I've found the Profile Exporter module a nice way to move sites between servers (like from local to web host).

You create the export profile using the module, copy the files to the new server, then go through the PW install process again. It will check all the permissions and install into an empty database you define. No need to mess with any SQL import / export.

https://github.com/r...ssExportProfile

#4 adamkiss

adamkiss

    Master of the universe

  • Moderators
  • 1,088 posts
  • 293

Posted 18 March 2012 - 08:09 PM

I actually am so lazy I have following in my config.php:

switch ($_SERVER['HTTP_HOST']){
	case 'www.domain.com': case 'domain.com':
		define('DEV_ENVIROMENT', 'LIVE'); break;
	case 'beta.domain.com': case 'staging.domain.com':
		define('DEV_ENVIROMENT', 'STAGING'); break;
	case 'www.domain.local': case 'domain.local': case '10.0.2.2': default:
		define('DEV_ENVIROMENT','LOCALHOST'); break;
}

on the top, and then on the bottom I have groups of configuration from the original generated config.php (well, one is generated, rest is copy-paste-change) in ifs:

if ('LOCALHOST' === DEV_ENVIROMENT):

This way, I only ddeploy database & code and everything is running like nothing ever changed :3

Of course, deployment strategies differ, when you need to sync data back and forth-for instance, on this one system I prepare and test any new stuff (even in db), import live (changed db) and recreate the db part of the new stuff (already programmed and tested) and push it back to production (or staging).

Edited by adamkiss, 18 March 2012 - 08:10 PM.
Note: the '10.0.2.2' is localhost from inside of VirtualBox :)


#5 alanfluff

alanfluff

    Sr. Member

  • Members
  • PipPipPipPip
  • 439 posts
  • 128

  • LocationOttawa, Canada

Posted 24 May 2012 - 07:42 AM

Thanks for the question @tinacious and answers @all, it's a reminder for me to do this stuff before I go live, can't have too many of them...

Thanks for the list @formmailer, the only two I would add are:
  • don't forget that you can have two config files, one to control your local (MAMP XAMP etc) environment (inc' db credentials etc) and another for the live/remote, see Maintaining a separate development configuration file. This is not really a thing to do at go-live time, but seemed worth noting in this context
  • once you have two config files, for your local file only, enable "$config->debug = true;" — I have just started doing this and already it uncovered something slightly dirty in my PHP for me to tidy up.
This ability to maintain local and remote configs is for me yet another differentiator for PW where something small yet really useful in the real-world has made it into production, a testament to the thought and care gone in to this product.

PS: UPDATE: I just remembered that assuming you use the above dual config files setup you need to configure your FTP client to not transfer a file called config-dev.php or the remote env' thinks it is a dev env ;) I just tripped myself over with that.

#6 tinacious

tinacious

    Full Member

  • Members
  • PipPipPip
  • 66 posts
  • 33

  • LocationToronto, Canada

Posted 08 June 2012 - 03:04 PM

Strange... This worked for me the first time and then I go to try it with another site it didn't work. Luckily, exporting and reimporting the SQL database is easy.

#7 alanfluff

alanfluff

    Sr. Member

  • Members
  • PipPipPipPip
  • 439 posts
  • 128

  • LocationOttawa, Canada

Posted 08 June 2012 - 03:11 PM

@tinacious [I'm not sure this explains anything you don't already know but]: I still need to export/import dbs (assuming I am developing locally then moving to a live host) it's just that when FTP up files as long as I don't include config-dev.php (I keep that local only) then the remote db credentials etc work immediately without having to go and edit a config file as the local settings are overridden by config-dev.php and the remote ones are setup in config.php.





Also tagged with one or more of these keywords: migration, moving

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users