Forum

Thread tagged as: Question, Configuration

How do I move my site between directories on the same server?

I know there are some similar posts about this, but I can't seem to find a simple set of steps to move my site from www.mysite.com/preview to www.mysite.com. I am worried about crashing my whole site in this process so I want to make sure I do it correctly.

Can anyone help?

PS. Perch, this would be a good tutorial to include in your support documents as I know I'm not the only one confused.

Sarah Barrable-Tishauer

Sarah Barrable-Tishauer 0 points

  • 7 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

We wouldn't suggest that you develop in a subfolder (whether using Perch or not) as to go live you are moving the path from root, so you are making a change to all of your paths etc. in the site.

We do have a tutorial for moving a site from staging or development to live and it is here:

https://solutions.grabaperch.com/development/how-do-i-move-a-perch-site

Thank you. I made the mistake of developing it in a subfolder and now I'm having to live with my mistake unfortunately. Being a bit of an unexperienced developer, the tutorial was still a bit confusing to me as I'm not sure which steps don't apply as I'm working within the same server and domain.

When I opened my config.php file to make those updates, it's blank - so do I need to add these lines?

define("PERCH_DB_USERNAME", 'root'); define("PERCH_DB_PASSWORD", 'xxxxxx'); define("PERCH_DB_SERVER", "localhost"); define("PERCH_DB_DATABASE", "db-site1");

I uploaded the files from the subfolder to the Public folder, but my content is missing. If I go to www.mysite.com/perch (the old location was www.mysite.com/preview/perch), it gives me the setup form.

How do I pair my new site location with the old database where all my site content is stored? Is this where the updating the config.php file comes in? Or do I just fill in the setup form?

Any help would be appreciated. Thanks!

Drew McLellan

Drew McLellan 2638 points
Perch Support

Your config.php file should not be blank. That's where your database connection information is held - Perch can't work without it.

Okay, thanks. I was able to retrieve the original config.php file. I updated the PERCH_LOGINPATH.

But now when I go to the www.mysite.com it says:

Forbidden

You don't have permission to access / on this server.

And is there a tidy way to update the file paths? Every time I try to change one in the Perch CMS under Page Options, the page gets messed up. Sometimes creating a new blank page. I've very confused. Sorry for being a squeaky wheel.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Your database details presumably haven't changed at all so the only thing you need to change is the path to Perch.

You then need to go into each page in Perch admin and adjust the path in Page Options. That's all you need to do.

I agree with sarah. I am an experienced developer and I also build each website in a subdirectory on my testing server. I realize this is not ideal but setting up a new server for each site and then turning those servers on and off each time i want to work on a different site seems ridiculous when I am often working on 4-5 sites a day. So "recommended" or not many web developers make our sites within a subdirectory on our testing servers, and we need a CMS that provides an easy way to migrate the site (and CMS) that allows us to change the site "home" directory even if this "home" directory is not the "root" directory. This was my first attempt at using your CMS and so far I am not impressed if you can not give me detailed instructions on how to migrate a site from one server to another server when the site resides in a subdirectory on one server and in the root of another.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

I explained what is required to Sarah.

You then need to go into each page in Perch admin and adjust the path in Page Options. That's all you need to do.

We wouldn't recommend developing like that, but if you do, that's what you need to do to fix it.

Rachel Andrew said:

I explained what is required to Sarah.

You then need to go into each page in Perch admin and adjust the path in Page Options. That's all you need to do.

We wouldn't recommend developing like that, but if you do, that's what you need to do to fix it.

I cant even log into perch on the new site once ive migrated servers. so how am I suppose to change the page options when I can not login?

Rachel Andrew

Rachel Andrew 394 points
Perch Support

That sounds as if you have some other issue.

I'd suggest starting your own thread explaining what you have done so far so we can help you.

Although an old thread, I will second the need for perch to support subdirectory development and release to a non subdirectory production. Since I develop and test many websites locally, It is an inconvenience to jump through hoops to support perch. Perch should do the hoop jumping as it would be good for developers and that would be good for perch.

Now it appears I have to write script to convert the database export to remove the subdirectory. Or is there a script available to do this?

This is the only thing that caught me out on using Perch for the first time. Everything else has been great. I develop in a subfolder in XAMPP (Surely it's impractical not to use subfolders when working locally?). So when I migrated everything was routed to the subfolder. Also all my pages were recreated on the live Perch Control panel, which I then had to delete, which in turn gave me 404's on the pages on my site so I had to reupload the necessary files.

I went through Page Options and removed the subfolder routing, which was fine. However any assets (images, PDF's etc) that I had uploaded in Perch, still had the subfolder path. So I had to go through and resave the assets, then they showed up. To clarify I didn't have to select the images again, they were already in place, I just had to resave them.

I too have run into a lot of trouble, being caught off-guard that Perch doesn't support developing in a subdirectory. It's a very common and convenient way to build sites (using MAMP, WAMP, XAMPP, etc).

For anyone that gets stuck like I did, you can make it work by using this handy (and free) database search-and-replace script: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ (It is advertised as being for wordpress, but it will work for any CMS) Here are the general steps involved:

  1. BACK UP YOUR DATABASE!!! (the script might mess it up, so make sure you have a backup to revert to in case of trouble)
  2. Download the script, unzip it, then put the folder onto your server's top-level directory.
  3. Visit the script folder in your browser. Enter the sub-folder you're moving from and the new one you're moving to (or if you're moving to the top-level of the domain, just leave the "replace" field empty). Also enter your db connection info. Do a "test run" to spot-check that it's performing the correct operation. Then do a real run.
  4. When you're done, click the "delete" button at the bottom of the script's page, or just delete the folder from your server. (VERY IMPORTANT: YOU ABSOLUTELY DO NOT WANT TO LEAVE THIS THING ON YOUR SITE FOR OTHERS TO STUMBLE ACROSS!)

You'll of course also need to change the PERCH_LOGINPATH in /perch/config/config.php

This did the trick for me, hopefully it helps others as well.