Jump to content
tinacious

Migrating ProcessWire from localhost to web host

Recommended Posts

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

  • Like 2

Share this post


Link to post
Share on other sites

Hi Tina,

Your steps cover most of the process.

A few notes:

  1. Make sure that the files/folders in the assets folder are writable
  2. Make sure to copy the the .htaccess file to the root of your website (some FTP programs hide this file by default)
  3. 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.
  4. 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

  • Like 6

Share this post


Link to post
Share on other sites

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/ryancramerdesign/ProcessExportProfile

  • Like 4

Share this post


Link to post
Share on other sites

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
Note: the '10.0.2.2' is localhost from inside of VirtualBox :)
  • Like 3

Share this post


Link to post
Share on other sites

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.

  • Like 4

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Thanks Tina for this post / question. I've used the Export Profile Module before, which is easy to use. Unfortunately it didn't export the roles, users, etc. This time i simply copied the files, exported + re-imported the databases into the new server, changed some permissions and the config file and that was it. Really mirrored my development site.

Although i still would prefer using a module that does all the work if possible.

  • Like 2

Share this post


Link to post
Share on other sites

@Alxndre': as far as I know, the (old) SiteExport-Profile in the modules directory still works with PW 2.4.0, but only for sites that do not use multilanguage fields. (and it does not export users / roles )

Share this post


Link to post
Share on other sites
On 3/19/2012 at 2:15 AM, Michael Murphy said:

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/ryancramerdesign/ProcessExportProfile

I was using this  method very recently, its very easy method to migrate from/to live + server. But recently, this method started to show some error, I posed a query here

Is it possible, because of the latest version, this module no longer works ? 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By alanxptm
      Hi, I have already tried in different ways and many times to migrate but I always have issues at the end.
      Here's what I have done so far:
       
      case 1:
      1. Install PW on live server (all normal)
      2. Import local DB into live DB
      3. Front page site seems to work but I cannot login into admin page
      case 2 (I'm currently on this stage):
      1. Copied all files from local to live server
      2. Import local DB into live empty DB
      3. Front page works, but any other page and admin page are 404
       
      In both cases:
      - I have changed config.php info accordingly to live server (DB name, DB user and pwd, userauthsalt code)
      - Uncommented RewriteBase / and RewriteBase /pw/ lines on .htaccess
      - applied owner and group permissions to www-data for PW location
      - applied permissions to folders and files accordingly
      - applied a2enmod rewrite to apache2 on live server and restarted service
       
      I have read some posts (Ryan's too) about migration and it seems to me that I'm doing it fine, don't know what it fails-
      I'm on VMWare machine, Ubuntu Server 18.04, php 7.2, phpMyAdmin 5.0.1
      Hope you can help me, thanks in advance
    • By franciccio-ITALIANO
      Hi, I must change server provider.
      I don't want rewtrite all page and articles, what must I do?
      I download a database copy on my pc, and now?

      Thanks!!
    • By joeck
      Hi Guys,
      I'm trying to do my first migration to the customers existing server (IIS 10) . I ran the site as a subdirectory on my website for test purposes (everything works fine).
      Following the tutorial of Joss, I tryed the site on a local xampp server to make sure, it also works on a root directory. So far so good, everything works.
      Now I moved the files (from the xampp) to the customers server. The root/index page is shown but for every subpage i get 404 Errors...
      Hence I followed the troubleshooting guide for not working URLs:
      On the first sight, the .htaccess file is not recognized, therefore I contacted the host support. They said, it is recognized but not all modules are supported in the processwire .htaccess file. I did the "öalskjfdoal" test in the .htaccess file and didn't get a 500 Error.... BUT the rewrite rule from the hosts support, to proof the file is read, DID work... The support claims, they do not provide debugging... so basically the .htaccess file is recognized and working, but not throwing any errors (for whatever reason).
      Working rewrite rule (from support):
      RewriteEngine On RewriteBase / RewriteRule ^test\.asp$ index.html [NC,L] RewriteRule ^test\.html$ konzept.html [NC,L] RewriteRule ^test2\.html$ team.html [NC,L] The support said, a couple modules are not supported in the htaccess file, the supported ones are listed here: http://www.helicontech.com/ape/ (I think mod_rewrite is supported)
      As I do not completely understand what exactly is happening in the htaccess file, I'm stuck. I tried all suggestions I found regarding this topic on the forum, but none of them solved the problem.
       
      .htaccess.txt
    • By Jota
      I need an expert in processwire (ver.2.3.0) to help us change a website of a hosting, contact info@intuitiva.com.co
    • By Inxentas
      I've got several Processwire websites running on a local server and an external server. With one of them I have the migration issue where anything but the homepage serves a 404 error. I've read pretty much all topics about the problem but can't seem to find a solution that works. Now in my situation, I request a new virtual domain (oisterwijk-cultuur.nl) for each website, and set an A record on our own domain (mallens-markhorst.nl). The end result:

      http://oisterwijk-cultuur.nl.mallens-markhorst.nl/
      So far so good, but only the homepage works. Subpages and the admin URL generate a 404. Most of the topics I read revolved around changing .htaccess but I've got similar websites running on the same testing server without any modifications. Example:
      http://moor-oisterwijk.nl.mallens-markhorst.nl/
      I've checked the .htaccess file line by line and even copied the one from working website into the non-working one, but to no avail. I tried upgrading PW but that didn't help either. Uploading and accessing a php file works, and mod_rewrite is on. Link to phpinfo() result.
      The document root in my FTP client is as follows: /data/www/oisterwijk-cultuur.nl.mallens-markhorst.nl/public_html
      I've tried uncommenting and changing the RewriteBase lines, tried both the full path as just '/public_html/', but unlike others there doesn't seem to change anything for me. I get the same plain 404 every time. Any ideas on what else I can try? Apart from a fresh installation?
      EDIT: I've just did a fresh install of PW 3.0.72 on the virtual domain, and it seems to have the same problem, I can't load the admin url.
×
×
  • Create New...