As many professionals know, pushing to production without testing can be very hazardous. It is an easy way to take your site offline or permanently lose data. To avoid that, we will cover setting up staging or development environments using your Webuzo control panel.
Domain vs Subdomain – Staging your site
For a WordPress site at https://www.yourdomain.tld/, there are many different options available to ensure your staging site is easy to use. Some prefer to buy a placeholder domain such as stagedomain.tld. This gives you a way to fully recreate the site and work with resource heavy plugins without using your primary account. This can save resources for sites with high traffic allowing you to avoid interrupting visitors.
Another popular option is using a subdomain under your account such as dev.yourdomain.tld or staging.yourdomain.tld. These share the same resources as your primary site and it is most suitable for small sites with less traffic. The specifics will depend on your needs and you can migrate it as your site grows. We will be using dev.yourdomain.tld today
Creating your staging environment
Log into your Webuzo control panel and click Subdomains. On the page, type dev or your choice of subdomain name and click “Add Domain”. This will create the new web address for your WordPress install. Next, click Database Wizard under Databases and follow the wizard to create your database for WordPress. You will need this in a few minutes.
You now have your MySQL database, access information for MySQL. and site URL. It is time to mirror your site files and setup the site. You can do this via the File Manager in Webuzo or via FTP from your local workstation.
We’ll be using the File Manager today.
Once in your File Manager, double click public_html. This will be where all your WordPress files are if your site is at https://www.yourdomain.tld/ or https://yourdomain.tld/ Next, click select all. This will highlight all files and folders in the public_html directory for you. Finally, hold the crtl button (or command button on MacOS) and click the folder you created earlier called dev. With dev not highlighted and the rest highlighted, click copy at the top, and type /dev so the box reads: /public_html/dev/ then click the Copy button.
You will see the items copying over in a dialog before finishing. If you see any errors, go back and make sure the dev or your named folder is not highlighted while the rest are.
Dumping Your Database
Under Databases, click phpMyAdmin. On the left, click the name of your production WordPress database. If you are unsure, check wp-config.php under your dev folder for the name. You will edit it there next.
After clicking the database, click Export at the top, and click the Export button. A download file dialog will appear. Save this to your computer. It might take awhile to export for very large sites.
Next, click the database you created earlier in database wizard, click Import, upload the file using File To Import: and click Import at the bottom. This may take a minute or two to upload for large sites.
Configuring WordPress
Finally, open wp-config.php under your dev folder and update the WordPress configuration.define( 'WP_HOME', 'https://www.yoursite.tld );
define( 'WP_SITEURL', 'https://www.yoursite.tld' );
define( 'DB_NAME', 'yoursite_wp1' );
/** Database username */
define( 'DB_USER', 'yoursite_wp1' );
/** Database password */
define( 'DB_PASSWORD', 'yoursitePASSWORD );
With these set, you should now be able to load your development and staging site successfully showing the same content as your primary site. You can consider password protecting the site or otherwise limiting access using methods like WordPress plugins or Directory Privacy in Webuzo. We’ll use Directory Privacy today.
Click Directory Privacy under Security, configure it for the dev directory created, and click Save. Now, you will have to enter a password before touching the site helping you limit access as it is in development.
Pushing staging to production
Backup your wp-config.php in public_html before proceeding!
Use the same process as before, copying from dev to public_html and importing your database. After import, you should see your site available and live with all updates. That’s it!
We hope this helps you update your site without fear of taking it offline due to a mistake. With this, you can try it again by copying the files or importing the database again if you need to.
Look forward to our next post!