Move WordPress from Shared Hosting to VPS — A Secure, Step‑by‑Step Guide

Move WordPress from Shared Hosting to VPS — A Secure, Step‑by‑Step Guide

Want to migrate WordPress to VPS without the stress? This friendly, step‑by‑step guide walks you through planning, secure transfer, and post‑migration hardening so your site gains speed, security, and full server control with minimal downtime.

Moving a WordPress site from shared hosting to a Virtual Private Server (VPS) is a common growth step for websites that need better performance, security, or configuration control. For site owners, developers, and agencies, a well-executed migration can reduce downtime, improve page load times, and enable server-level optimization that shared hosts simply can’t provide. This guide walks through the technical rationale and provides a secure, step‑by‑step migration path — from planning to post‑migration hardening — plus practical recommendations for choosing a VPS.

Why move from shared hosting to a VPS (technical rationale)

Shared hosting is inexpensive and convenient, but it has intrinsic limits because many tenants share the same OS, kernel resources, and software stack. Moving to a VPS gives you:

  • Dedicated resources: guaranteed CPU, RAM and I/O allocations improve performance consistency under load.
  • Full stack control: you can choose OS, web server (Apache or Nginx), PHP version, PHP-FPM tuning, and database configuration.
  • Better security isolation: your environment is separate, reducing “noisy neighbor” risk and allowing server hardening practices like firewall rules, SELinux/AppArmor and custom user management.
  • Advanced caching and optimizations: server‑level caching, opcode caches (OPcache), Redis or Memcached, and HTTP/2 or QUIC support.
  • Scalability: easier vertical scaling (more CPU/RAM) and snapshot-based backups for fast recovery.

When a VPS is the right choice (use cases)

Consider a VPS when any of the following apply:

  • Traffic growth causes frequent timeouts or slow admin operations.
  • You need server access for installing custom services, cron jobs, or specialized PHP extensions.
  • Security compliance requires isolation and control over updates, firewall, or logging.
  • You run multiple sites or containerized applications and want consolidated management.

Pre-migration planning (essential checks)

Careful planning reduces downtime and avoids surprises.

  • Inventory your stack: WordPress core version, PHP version, active plugins & themes, MySQL/MariaDB version, .htaccess rules, scheduled tasks (WP-Cron), email sending method (SMTP, sendmail).
  • Take full backups: export the database (mysqldump), copy the wp-content directory, and save wp-config.php + any custom files. Always verify backup integrity by opening SQL files with a text editor and checking file sizes.
  • Choose an OS and software stack: typical choices are Ubuntu LTS, Debian, or CentOS/Alma/Rocky. Decide between LAMP (Apache) or LEMP (Nginx + PHP-FPM) depending on rewrite rules and performance needs.
  • Decide managed vs unmanaged: managed VPS includes OS and security maintenance (recommended for less ops experience). Unmanaged gives more control but requires sysadmin skills.

Step‑by‑step migration procedure

1. Provision the VPS and secure initial access

  • Create the VPS instance with the chosen OS and disk type (prefer SSD). Allocate adequate RAM/CPU for expected peak traffic (e.g., 2–4 vCPU and 4–8 GB RAM for medium sites).
  • Set up SSH key authentication and disable password login for root. Example SSH config addition: PermitRootLogin no in /etc/ssh/sshd_config.
  • Create a non-root sudo user: adduser deploy && usermod -aG sudo deploy.
  • Install and enable a basic firewall (ufw on Debian/Ubuntu): ufw allow 22/tcp; ufw allow 80,443/tcp; ufw enable.

2. Install and configure the web stack

  • Install web server and PHP: for Nginx + PHP-FPM: apt install nginx php-fpm php-mysql php-xml php-gd php-curl php-mbstring. For Apache with mod_php or PHP-FPM: adjust accordingly.
  • Tune PHP-FPM pools: set pm = dynamic and configure pm.max_children, min/max spare servers based on RAM and average PHP process size.
  • Enable OPcache in php.ini and set memory and revalidation settings for performance.
  • Install MySQL or MariaDB and perform secure installation (mysql_secure_installation).
  • Create a database and user for WordPress with least privilege: CREATE DATABASE wpdb; CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'strongpass'; GRANT ALL PRIVILEGES ON wpdb. TO 'wpuser'@'localhost'; FLUSH PRIVILEGES;.

3. Transfer files and database

  • Disable caching plugins and set WordPress into maintenance mode to prevent content changes during transfer.
  • Use mysqldump on the shared host: mysqldump -u root -p wpdb > wpdb.sql.
  • Securely copy the database and files to the VPS using scp or rsync over SSH: rsync -avz --progress user@shared:/path/to/wp-content /var/www/site/wp-content and scp wpdb.sql user@vps:/tmp/.
  • Import the SQL dump into the VPS database: mysql -u wpuser -p wpdb < wpdb.sql.
  • Copy wp-config.php and update DB credentials, table prefix, and any custom constants (WP_HOME, WP_SITEURL if necessary).

4. Configure virtual hosts/server blocks and SSL

  • Create an Nginx server block or Apache VirtualHost pointing to your WordPress directory. Ensure proper handling of permalinks (.htaccess rules for Apache or try_files for Nginx).
  • Install Certbot and obtain a Let’s Encrypt certificate: certbot --nginx -d example.com -d www.example.com or use the Apache plugin.
  • Enable HTTP/2 in your server configuration when using TLS for improved performance.

5. File permissions and ownership

  • Set ownership to the web server user: chown -R www-data:www-data /var/www/site (www-data on Debian/Ubuntu; nginx or apache on other distros).
  • Use restrictive permissions: directories 755 and files 644. Only allow 775/770 for uploads if necessary.
  • If SELinux is enabled (CentOS/Alma), ensure proper contexts: chcon -R -t httpd_sys_rw_content_t /var/www/site/wp-content.

6. Update DNS and cutover

  • Lower TTL on your A record at the registrar a day before the move to speed propagation (e.g., to 300 seconds).
  • When ready, update the A record to the VPS public IP. Monitor DNS propagation and traffic using access logs and analytics.
  • Keep the old server running for a short rollback window until DNS fully converges.

7. Post-migration tuning and secure hardening

  • Replace WP-Cron with a real cron job for reliability: in wp-config.php add define('DISABLE_WP_CRON', true); then add a system cron: /5 wget -q -O - https://example.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1.
  • Install fail2ban and configure jails for SSH and web application logs to guard against brute force attacks.
  • Harden PHP: disable dangerous functions (exec, shell_exec) if not needed, and set open_basedir to the site directory.
  • Set up automatic updates or a controlled patching plan for OS packages and PHP/MySQL to reduce exploit risk.
  • Configure daily backups (database + files) and a snapshot/restore plan with your VPS provider.
  • Implement monitoring: uptime checks, disk I/O, and MySQL performance metrics. Tools like Prometheus/Grafana, New Relic, or simple scripts + alerts are helpful.

Performance considerations and server tuning

To get the most from your VPS:

  • Use server-side caching: Nginx FastCGI cache, Varnish, or plugin-level full page caches (with care). Combine with object caching (Redis or Memcached) for DB query reduction.
  • Tune MySQL/MariaDB with a tool like mysqltuner and adjust innodb_buffer_pool_size to ~60–80% of available RAM for dedicated DB instances.
  • Enable OPcache and set memory_size appropriate to your codebase; reduce PHP-FPM spawn overhead by sizing pools correctly.
  • Consider using a CDN for static assets and HTTP/2/QUIC support to reduce latency for global visitors.

How to choose the right VPS (practical buying advice)

Key factors to weigh when selecting a VPS:

  • CPU and RAM: for WordPress, CPU single-thread performance matters; prioritize higher clock speeds for smaller instances and scale cores for concurrency.
  • Storage: NVMe/SSD is critical for fast database performance. Ensure sufficient IOPS and avoid oversold storage offerings.
  • Network bandwidth and latency: choose a provider with good peering and locations near your primary audience. For U.S. audiences, a U.S.-based VPS can lower latency.
  • Snapshots and backups: provider snapshots simplify rollbacks and upgrades — ensure retention meets your RTO/RPO requirements.
  • Support level: experienced sysadmins benefit from unmanaged plans, while teams focusing on content & development may prefer managed services.
  • Security features: built‑in DDoS protection, private networking, and firewall controls are valuable.

For U.S.-hosted projects aiming for a balance of latency and legal jurisdiction, consider U.S. VPS locations that offer SSD storage and predictable network throughput.

Summary

Moving WordPress from shared hosting to a VPS delivers clear benefits in performance, control, and security — but it requires disciplined planning and careful execution. The core migration tasks are: provision and secure the VPS, install and tune the web stack, transfer files and database safely, configure DNS and SSL, and perform post‑migration hardening and monitoring. With proper backups, cron management, caching, and resource allocation, a VPS can significantly improve user experience and operational flexibility.

If you’re evaluating hosting options and need a U.S.-based VPS with SSD storage and reliable network performance, you may find a suitable plan at VPS.DO USA VPS. They offer snapshots and configurable resources that simplify the migration and scaling process without forcing a managed service model, which can be useful for teams that want full server control.

Fast • Reliable • Affordable VPS - DO It Now!

Get top VPS hosting with VPS.DO’s fast, low-cost plans. Try risk-free with our 7-day no-questions-asked refund and start today!