Going Live Start To Finish
Going live is hard at any host. Especially if its an existing site. Every duck has to be in a row to minimize downtime and keep your store running. This guide is intended to be an example and may not fit every case when moving to Mojo Stratus. Contact MageMojo support with any specific questions.
Preparing Your Stratus Environment
Now to prep your environment, gather the following information if you do not already have it.
- Magento version (1 vs 2)
- PHP version at the current host
Next, set your Stratus environment to match the PHP version and Stratus template based on the table below. Note that PHP 5.6 and 7.0 are end of life. The default configuration for new Stratus environments is our Magento 2 template with PHP 7.1
Clear The Existing Install
All new Stratus environments have Magento 2 pre-installed with the document root at /srv/public_html/. Before you can copy your site, you need to clear this data.
- Delete everything in public_html/ with rm -rf /srv/public_html/
- Using the database credentials from the MySQL -> Info section , drop and recreate the existing database via SSH in your Stratus environment. Substitute the appropriate creds in the example below.
bash mysqladmin -h mysql -u user_ -pPASSWORD drop db_ mysqladmin -h mysql -u user_ -pPASSWORD create db_
Now you are ready to move your own files and database into the Stratus environment.
Copying Your Site
Copying your site over requires SSH access to your current host. Make sure that is available and working from your Stratus environment. Confirm by logging into your Stratus environment through SSH and connecting:
If you can connect, great! You might have custom ports or even require a key, leading to these variants of the SSH command.
#with key ssh -i /path/to/keyfile firstname.lastname@example.org #with custom port ssh -p 1234 email@example.com
With SSH access in hand, you should connect to your current host and create a database backup. The popular n98 tools make this easy, you can download them to your current host in .phar format and run the db:dump commands (see below). To grab the tools check out the Magento 1 and Magento 2 versions. Put the dump file somewhere restricted from web access. Within the Magento doc root inside app/etc/ is a good place.
#example database dump commands mysqldump -uUSERNAME -pPASSWORD databasename > migrate.sql #with n98 n98-magerun db:dump migrate.sql
Now you can copy your files and database dump over to Mojo Stratus. The easiest way is with rsync. Rsync is installed in all Stratus environments and most Linux environments everywhere.
From SSH in your Stratus environment, do the following:
- Go to your document root, in this case public_html/
- Run the command
rsync -avz -e ssh myuser@mycurrenthost:/path/to/webroot/ .
If you have a custom port or ssh key, you need additional quotes around the SSH command
rsync -avz -e "ssh -p 1234" firstname.lastname@example.org:/path/to/webroot/ .
- The copy will begin. If you have a lot of media and/or a large database this will take a long time. Output will stream onto your terminal screen.
Initial Magento Configuration
If the files and database dump transfer are complete, you can start configuring Magento within your Stratus environment.
First, update local.xml (Magento 1) or env.php (Magento 2) in app/etc with the proper database credentials from the MySQL -> Info section of the management panel. Make sure to set the hostname to mysql, on many other environments the hostname is just localhost and left as the default!
In Magento 1 you would see:
<resources> <db> <table_prefix><![CDATA]></table_prefix> </db> <default_setup> <connection> <host><![CDATA[mysql]]></host> <username><![CDATA[USERNAME]]></username> <password><![CDATA[PASSWORD]]></password> <dbname><![CDATA[DATABASENAME]]></dbname> <initStatements><![CDATA[SET NAMES utf8]]></initStatements> <model><![CDATA[mysql4]]></model> <type><![CDATA[pdo_mysql]]></type> <pdoType><![CDATA]></pdoType> <active>1</active> </connection> </default_setup> </resources>
In Magento 2 that block looks like this:
<? php 'db' => [ 'table_prefix' => '', 'connection' => [ 'default' => [ 'host' => 'mysql', 'dbname' => 'DATABASENAME', 'username' => 'USERNAME', 'password' => 'PASSWORD', 'model' => 'mysql4', 'engine' => 'innodb', 'initStatements' => 'SET NAMES utf8;', 'active' => '1' ] ] ], ?>
Import The Database
n98-magerun, once again, provides the perfect tool for importing a database. Do that with the built-in db:import command.
#from your Magento document or web root #magento 1 n98-magerun db:import app/etc/mydump.sql #magento 2 n98-magerun2 db:import app/etc/mydump.sql
The pv utility shows the progress while the import completes.
Next enable Redis cache for Magento 1 or 2 per our guide.
Confirm Redis is enabled via the n98-magerun sys:info command (or n98-magerun2). On the Cache Backend line you will see:
| Cache Backend | Cm_Cache_Backend_Redis
We recommend using redis for your sessions. As with the cache, you can enable it via the Magento configuration file and confirm with n98, see our redis sessions article.
Update Base URLs
The base URLs control the domain Magento servers your store on. There may be several different base URLs if you are operating a multi-store. The example here is for a simple store with only one core view and a single domain in the base URLs.
You can test your site with the pre-configured and include mojostratus.io subdomain. That domain is always the UUID of your Stratus environment. And the UUID is a longer string of random letters and numbers similar to a hash.
See our how-tos on updating base URLs for Magento 1 and Magento 2.
Make sure to use the proper mojostratus.io subdomain. If you prefer you can use your own sub-domain for testing. For setting up your own domain for testing, read these guides:
You should see the frontend of your store on a temporary domain at this point. If not, please review the previous steps and configuration. Otherwise, you can test your site. Our general recommendation is to look at as much as you can and work on the site as you would on production, especially backend work. Doing your day to day on the test copy should show any obvious errors that could stop you from going live.
Check things such as:
- Product pages
- Category pages
- Add to cart functionality
- Logging into the backend
- Any special modules you use
- Cron configuration
If something does not work, hopefully it gives you an explicit on-screen error. If not check:
- Chrome console for error output
- Magento logs
- Error logs for Nginx in /log/error.log
- PHP error logs in /log/php-fpm/
- Check with MageMojo Support if all else fails
Preparing For Going Live
Switch Nameservers Ahead
The time delay for DNS propagation can be up to 24 hours. A popular solution to the propagation problem is to set all records to very low TTL. However, not all ISPs and network care what your TTL is and may ignore it.
When switching to Stratus, you have a few options laid out in our DNS guide. Here we are assuming you are switching all your domains to use Route 53 through the Stratus Management panel.
When switching to Route 53, we recommend switching your nameservers ahead of time. Then propagation is not an issue at all as all nameservers available will point to your current host. To switch nameservers, follow these steps:
- Get the current IP or IPs for each domain at your current host. You may have to contact your current host’s support. Likely the IP can be obtained via DNS/dig query.
- Open the DNS section of your Stratus Management panel. Select a zone from the list. You will switch the nameservers for this zone.
Click the Custom IP bubble and enter the IP addressed used by your domain at the current host.
- Click Update near the bottom right to apply the change.
- At your domain’s registrar (typically where you bought the domain) change the nameservers for your domain to the 4 listed at the top of the zone.
- Make sure to update any records for www, and other sub-domains to point back to your current host in the rest of the zone file!
- Repeat previous steps for every domain in your Stratus environment
Now wait 24 hours to allow the nameserver change to propagation.
Your store may have a lot of extra integrations, frameworks, and custom code to account for outside the scope of this guide. Consider the list below but keep in mind the devil is always in the details!
- Check all your DNS zones for any custom records that link to websites maintained at other hosts (subdomains etc) or custom TXT/SRV records for validation
- Check all cron jobs are configured under the Cron Management area needed for your store, including any custom jobs from your current host.
- Verify any non-Magento code/frameworks are working as expected (namely WordPress!)
- If you are a developer or other technical contact moving a site for a merchant, make sure the merchant and any other parties know you will be moving the site!
The big day is here, follow these steps to complete your transfer to Mojo Stratus.
- Place your Magento store at your current host into maintenance mode to prevent further orders. Failure to do so can cause a split DB situation where you have the same order numbers in two different databases and the orders themselves are different. See Magento Maintenance
- In the DNS zones listed under the DNS section, adjust all the zones to point to the CloudFront endpoint instead of your current host, if you chose to switch the nameservers ahead. Otherwise, you must switch the nameservers now.
- Similar to the Copying your site section, re-copy your store database over to Mojo Stratus and any updated files. Make sure to drop the existing database first, then re-import it. Don’t overwrite your updated configuration files or you’ll have to re-do them.
mysqladmin -h mysql -u user_ -pPASSWORD drop db_ mysqladmin -h mysql -u user_ -pASSWORD create db_
- Go to the URLs area of the Stratus management panel. Make sure all the domains listed match the domains you are moving, including their www. form i.e. mysite.com and www.mysite.com, see Stratus URLs List and Domains
- Waiting 15-30 minutes after updating the URLs list. That list controls the domains in your CloudFront distribution and the domains sent for Lets Encrypt validation. During that update a Lets Encrypt certificate will be generated and applied.
- Adjust your multi-store configuration to match the live domains.
- Disable maintenance mode on the Stratus side, do not disable maintenance mode on your old host
- Verify your site loads, you are live!
Troubleshooting And Final Check
- Repeat the initial testing for basic store functionality
- Test the checkout
- Check all caches and performance settings, review Magento Performance FAQ
- Contact MageMojo Support if things get hairy!