Roots Discourse

Staging on a subdomain / .env file question

Hello,

I’ve got some questions regarding Capistrano deployment

  1. I’ve set up my staging env on a subdomain relative to the main domain which will host production website - is this a good practice, first of all?
  2. I was not able to find this information anywhere, but after deploying the site for the first time to staging environment, I had to actually perform a regular wordpress install by going to the wp/wp-install.php (of course db was created earlier as the .env file needed the db data)… just a note.
  3. I’ve created .env file with staging info, and put it to /my-app/shared directory. Now, where do i put the production .env file? This part is kinda confusing for me, I’ve watched the screencast and all, and I can’t figure this out.

Thanks!

  1. If you mean something like stage.domain.com, I think it’s a good strategy.

  2. WP can’t very well run without its basic db-content. If feasible, you could export your local db, replacing local urls with stage, and insert it directly to your db and then you would be good to go without manually installing.

  3. Stage and prod should not share any files or data. Instad, install the stage-environment in its own directory so everything for stage, including the .env-file, is completely separated from prod. If you are developing php-scripts that may cause heavy load on the server if anything goes wrong on stage, you may want to consider even having separate servers for stage and prod.

Disclaimer: the above is how I do it and it works-for-me™ :slight_smile:

1 Like

Thanks @folbert! That clears it for me, it seems I couldn’t wrap my head around some of those. The screencast assumes that staging and production are on different hosts (roots.dev & roots.io), in my case it’s the same and that was the confusion - so I should have figured this out :wink: Thanks again!

:+1: Glad to be of service.

I am guessing that they are using a .dev domain in the screencast since the stage-env. is really just a local Vagrant box (for demoing purposes I assume) and the screencast is from that ancient time when .dev was used for local development domains :slight_smile: I can see why it’s confusing a cpl of years later.

@folbert I have to step back and ask again about the staging/prod, more specifically:

In order to achieve what I want, I need to specify that the folder names for staging and prod are different. There was a common “:deploy_to” setting in the deploy.rb file, so I just moved it into staging.rb & production.rb files, specifying different folder name for each. Is that the way to go? It works, so at least that part is fine :slight_smile:

I believe that’s exactly what staging.rb and production.rb are for: to set environment specific variables.

I have done the same for a multitude of projects and haven’t had any troubles with it so I can’t see anything wrong with it :slight_smile:

1 Like