Turn my staging server to production

Hi,

I just finish a website, and during the developpement, we’ve deploy to a staging server ( digital ocean ).
Now can i just turn this staging server to production by putting the staging variable in the production ansible file and keep my db ?

Sorry if i’m not clear ^^’

Thanks :slight_smile:

PS : Is there a difference between staging and production in treillis ?

1 Like

The recommended process is to set up a second server for production. You can always tear down Staging when you’re finished if you no longer need it.

You’ll need to migrate the database and uploads from staging, which is pretty easy:

Uploads
Download the /srv/www/example.com/shared/uploads directory using (s)FTP

Database
ssh to the staging site:

ssh web@staging.example.com

Change directories to the current deployment:

cd /srv/www/example.com/current

Export the database:

wp db export

Download the exported file with (s)FTP or whatever other method you prefer.

Create and provision your production server.

Deploy to the production server.

Copy the uploads directory into the production server’s /srv/www/example.com/shared directory with (s)FTP.

Copy the database export from earlier into /srv/www/example.com/current

ssh to the production server:

ssh web@example.com

Change directories to the current deployment:

cd /srv/www/example.com/current

Reset the database for good measure:

wp db reset

Import the database export from staging:

wp db import [export file name].sql

Replace staging URLs with production URLs:

wp search-replace staging.example.com example.com

And that’s it!

2 Likes

Here’s a script you might find useful:

3 Likes

Thanks a lot :wink: I will do that.

This topic was automatically closed after 42 days. New replies are no longer allowed.