CloudInsidr

Cyber security, infotech

  • Subscribe!
  • Privacy Policy
  • Legal
  • Contact Us

Join us on Twitter: @CloudInsidr

Follow us on Twitter: @cloudinsidr
  • news & alerts
    • events
    • industry analysis
    • industry gossip
    • people
  • cloud, edge & co.
    • AWS
    • administration & orchestration
      • web servers in the cloud
      • mail servers
      • databases
  • cybersec & warfare
    • encryption
  • blockchain
Home cloud, edge and everything in between How to migrate your web services from any hosting provider to AWS
How to migrate your web services from any hosting provider to AWS

Cloud Insidr 2015-02-25 Leave a Comment

How to migrate your web services from any hosting provider to AWS

Leaving your current web hosting provider for the cloud experience may feel rather scary, but in reality, it is a liberating experience.

Just think of all the freedom you gain to run your web services your way: the ability to use any DNS provider of your choice, any certificate authority (such as, most notably, the disruptive force of Letsencrypt), install software to your heart’s content, scale up and out on demand, in other words, be in charge of your own services and infrastructure. Here is a quick tutorial on how to make the leap.

There are quite a few important considerations when migrating a web site. Are you switching from a control panel-enabled hosting to a “raw” infrastructure-as-a-service offering? (In case of AWS EC2, the answer is yes; in case of AWS Lightsail, both yes and no.) Are you also changing your web server software (for example, from Apache to NGINX), changing the SAPI, upgrading the PHP engine to take advantage of improved security and higher performance, and/or possibly the database server in the process as well? Here is a comprehensive tutorial on how to set up your new server on Linux with NGINX, PHP, and MySQL/MariaDB: High-Stakes, High-Security LEMP Setup: Nginx with MariaDB/MySQL, and PHP 7.x on CentOS 7 (RHEL/Fedora) with SELinux.

One of the most important questions is how to minimize the downtime. The answer is: by being smart about the DNS switch from the old to the new server.

Step 1. Make a backup followed by an update, then another backup

Backup your CMS “as is” on the current host. Once you have a backup, update all relevant software on both systems, then run a backup again.


Quick Tip: Freeze the File System

If you are running on xfs, btrfs, ext3, or ext4 and happen to be paranoid, you probably want to make sure no data is lost in the course of a backup. The solution is to freeze and unfreeze the file system as per Oracle’s directions found here:

# xfs_freeze -f /myxfs # # ... Take snapshot of file system ... # xfs_freeze -u /myxfs

Step 2. Install WordPress on the destination host

As soon as your web server with PHP and MySQL/MariaDB is up and running, wget WordPress and follow the usual installation instructions. On systems with SELinux, you will need to adjust SELinux labels on the file system and allow access to TCP sockets.

Step 3. Migrate your data: uploads, themes, plug-ins, and database(s)

You could dump the databases and rsync the servers, and many people do just that. However, there is an easier way, try it and it will make your jaw drop: the All-In-One WordPress Migration Plug-In. It can even make replacements (for example, replace the old host name with a new one) in the database if needed.

Step 5. Adjust the domain name which WordPress identifies with

Now this part is tricky. You said you wanted to minimize downtime (and who doesn’t!), here is how to do it:

  • make sure that the TTL for your domain is as short as possible (depending on your current setup, you may need to wait a couple of hours for the new setting to propagate so that it will be respected when you perform the DNS switch; you will reverse this setting afterwards),
  • set up WordPress with all your content on your new server using a temporary host name such as www7.yourdomain.tld by enforcing the name switch the the wp-config file of your site’s configuration (see below for details),
  • verify that everything is working on the new (temporary) host name,
  • change the web server configuration on your new server to include your usual main (SEO-ranked) hostname www.yourdomain.tld so that when you switch the DNS to the new server, it will answer requests (up to that point, requests won’t be routed so the server can only respond to the temporary host name),
  • remove the lines that enforce the temporary name in wp-config so that WordPress will continue to identify with its usual, SEO-ranked host name (if you made replacements in the database, you should probably reverse them; the amazing All-In-One WordPress Migration Plug-In can take care of that for you by exporting and re-importing the database on the new server with replacements in place),
  • at this point WorPress isn’t working correctly on the new server (links will be redirecting to your old server that is receiving requests on your standard host name) but that doesn’t matter, you are ready to switch the DNS from the old to the new server.

All your users who were signed in must sign in again, obviously, but other than that, the downtime should be minimal.

Here is the snippet to enforce a host name in the wp-config.php file of your WordPress installation to define how WordPress identifies itself; should you need it, it’s very handy:

define('WP_HOME','https://www.yourdomain.tld/somedirectory');
define('WP_SITEURL','https://www.yourdomain.tld/somedirectory');

If hard-coding the “installation identifier” is not appealing to you, you could enforce an update of the host name by putting a directive into your theme’s functions.php file, reloading the site a couple of times, and removing these once the change has taken place (check the Codex for more details):

update_option( 'siteurl', 'https://www.yourdomain.tld/somedirectory' );
update_option( 'home', 'https://www.yourdomain.tld/somedirectory' );

Just remember to remove the two lines from your functions.php when they are no longer needed (which is, as soon as the update takes place).

Step 6. Reconfigure DNS

Now is the time to point the DNS configuration away from the old instance to the new server instance. Verify that the site is running (should it need some major troubleshooting, reverse the last DNS change to temporarily revert to the old server). When you are done, shut down the old server so it will not be serving requests.

You may want to increase the TTL in the DNS configuration for your domain to reduce unnecessary expenses (you won’t be migrating anything anytime soon, so your setup won’t be changing).

Step 7. Celebrate

Filed Under: cloud, edge and everything in between, NGINX, web servers in the cloud Tagged With: AWS, EC2, Linux, NGINX, WordPress

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Subscribe

SSL/TLS Certificate Square (250 x 250)

Pearson Education (InformIT)

SSL/TLS Certificate Medium Rectangle (300 x 250)

Recent Posts

  • Upgrading from CentOS 6 to CentOS 7 and Beyond?
  • How To Figure Out Who is Signing In To Dovecot to Send or Retrieve Email
  • OpenSSH 9.9 Introduces Enhanced Quantum-Resistant Algorithms
  • OpenSSL 3.3 Final Release is now live!
  • How to Activate HTTP/2 with TLS 1.3 Encryption in NGINX for Secure Connections without a Performance Penalty
  • Is AWS sucking your budget dry? Strip it down to the nitty-gritty (without breaking stuff)
  • How to attach and mount an NVMe EBS volume on EC2
  • SELinux security contexts: correcting SELinux labels on a file system
  • Intel gobbling up Israeli Tower Semiconductor, Stock Goes Through The Roof
  • NGINX on AWS EC2: setting up a web server from scratch on a domain of your choice
  • Log4j RCE and mitigation techniques
  • Set up logrotate for Postfix

Symantec

Categories

  • administration and orchestration
  • alerts
  • AWS
  • Bitcoin
  • cloud, edge and everything in between
  • cryptocurrencies
  • cybersecurity and cyber warfare
  • databases
  • DNS
  • encryption
  • events
  • FinTech and InsurTech
  • homeland security
  • HTTP Security Headers
  • industries
  • industry analysis
  • industry gossip
  • Java
  • Linux
  • mail servers
  • networking
  • news
  • NGINX
  • people
  • php-fpm
  • reviews
  • SELinux
  • tips and tricks
  • Uncategorized
  • web servers in the cloud

Tags

AMI AWS AWS EBS Azure certificate cipher suites cryptography cyber defense cybersecurity cyber security Diffie-Hellman DNS DNS over HTTPS Dovecot EBS EC2 email encryption Fedora HTTP/2 HTTPS IBM letsencrypt Linux logs MariaDB MFA MySQL NGINX OpenSSL permissions php-fpm PHP 7 postfix RegEx Route 53 RSA SELinux SQL SSH SSL TLS TLS 1.3 TLS vulnerabilities WordPress

Archives

  • January 2025
  • November 2024
  • October 2024
  • May 2024
  • January 2023
  • March 2022
  • February 2022
  • December 2021
  • December 2020
  • November 2020
  • September 2020
  • January 2020
  • November 2019
  • August 2019
  • July 2019
  • April 2019
  • December 2018
  • October 2018
  • September 2018
  • August 2018
  • June 2018
  • May 2018
  • April 2018
  • February 2018
  • December 2017
  • November 2017
  • October 2017
  • August 2017
  • April 2017
  • February 2017
  • January 2017
  • November 2016
  • September 2016
  • August 2016
  • July 2016
  • March 2016
  • February 2016
  • January 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • July 2015
  • February 2015

Recent Comments

    Wicked fast Networking (With a Government Clearance to Boot)

    ©2022 CybrAnalytiqa OÜ

    • Content purchasing and syndication