We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question, Problem, Configuration

Running Perch on Localhost

I recently changed how I work with sites locally so that I can better integrate with a studio I'm working with. I had previously been using domain.test but they have a number of people they work with who use localhost/site alongside remote databases to ensure everyone is working from the same content.

For WordPress sites this has not been an issue, but it has broken all my Perch sites. I can access the admin areas at localhost/site/perch and it works fine, however viewing localhost/site doesn't function properly (CSS doesn't get loaded, and links are treated as if they are localhost/link instead of localhost/site/link). If I temporarily point MAMP to user/sites/site rather than user/sites/, to make the perch site the target, I can view the site fine, but I'm unable to login to Perch and no library assets load.

Is there anyway to make Perch work with this setup?

Phil Bowell

Phil Bowell 0 points

  • 1 year ago

Hi Phil

Create a virtual host for each website you are working on. You can do this in the control panel of Mamp Pro or manually with vanilla MAMP.

If you are using root relative paths on assets then it shouldn't matter what the domain is called when you are working this way. i.e. /root/folder/filename not root/folder/filename.

Jon

Hi Jonathan,

Thanks for your reply. If I do this I'm able to work on my Perch sites, but of course it breaks the ability to use localhost/site inline with the studio sites. Is there no way to use Perch in the same manner as with the Wordpress sites by visiting localhost/site?

I'm not sure I understand why you have to have that domain structure but I know that Perch doesn't like running in a subdirectory. Maybe someone else here has experience of that - I always run in root myself.

It shouldn't really matter what domain you use if you are working remotely from the other team members because Perch uses relative paths – unlike Wordpress which hardcodes the domain into links (or did when I last used it, which might be why they work this way).

Thanks Jonathan, the issue is because of the shared database which has the site url stored within it, I go in and work in the studio on the design side of things, but they have devs who work remotely and use the same shared database so we don't have to keep updating databases all the time. I suspect it's the subdirectory issue that I'm encountering.

Further on this, I've now returned to using local domains as I need to work on a Perch site. I'm now receiving an error when I try to login to perch

Debug Message - Perch 3.0.13
[61] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
Queries: 1
Memory: 1.3318

Perch is still trying to find itself at localhost/site/perch. I've updated the mysql siteURL to match my new local domain but that doesn't seem to have fixed it.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is there no way to use Perch in the same manner as with the Wordpress sites by visiting localhost/site?

Not really, as this is not a great practice. I wrote about this here: https://allinthehead.com/retro/352/stop-building-sites-in-subfolders

I'm now receiving an error when I try to login to perch

What error are you receiving?

Well, I'm getting the Debug message in my post above before I attempt a login and then when I submit my login details it's not picking up the new virtual host.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Not the debug, what does the error message in the UI say?

My apologies, I read the debug as an error. When I try and login it redirects to localhost/site/perch instead of the new local site domain/perch.

Is there another place in the database I need to update the url? I've currently edited perch2_settings - siteURL to match my new local domain and the site itself loads, but the Perch admin area isn't accessible as if it's ignoring the changed siteURL.

Edit: It seems that Fetching the site from Git has refreshed it and now I'm able to get into Perch.