Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the updraftplus domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/borrowvision.pro/wp-includes/functions.php on line 6114
How to Migrate WordPress to Another Domain: A Step-by-Step Guide – Rent Vision Pro In Austin

How to Migrate WordPress to Another Domain: A Step-by-Step Guide

Migrating a WordPress site to a new domain can seem daunting, but with the right steps, it can be smooth and error-free. This guide will walk you through the process from start to finish.

Step 1: Set Up Apache Virtual Hosts

First, you need to configure Apache to serve your site from the new domain. Create virtual host files for both HTTP (port 80) and HTTPS (port 443).

Creating Virtual Host Files

sudo touch /etc/apache2/sites-available/newsite.com.conf
sudo touch /etc/apache2/sites-available/newsite.com-le-ssl.conf

Add the following configurations:

For HTTP (newsite.com.conf):

<VirtualHost *:80>
    ServerName newsite.com
    ServerAlias www.newsite.com
    DocumentRoot /var/www/newsite.com
    ErrorLog ${APACHE_LOG_DIR}/newsite.com/error.log
    CustomLog ${APACHE_LOG_DIR}/newsite.com/access.log combined
</VirtualHost>

For HTTPS (newsite.com-le-ssl.conf), ensure you have a Let’s Encrypt certificate:

<VirtualHost *:443>
    ServerName newsite.com
    ServerAlias www.newsite.com
    DocumentRoot /var/www/newsite.com
    ErrorLog ${APACHE_LOG_DIR}/newsite.com/error.log
    CustomLog ${APACHE_LOG_DIR}/newsite.com/access.log combined
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/newsite.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/newsite.com/privkey.pem
</VirtualHost>

Activate the new virtual hosts:

sudo a2ensite newsite.com.conf
sudo a2ensite newsite.com-le-ssl.conf

If you don’t have a Let’s Encrypt certificate yet, use Certbot to obtain one:

sudo certbot --apache -d newsite.com -d www.newsite.com

Step 2: Copy WordPress Files

Copy your WordPress files to the new directory:

sudo cp -a /var/www/oldsite.com/. /var/www/newsite.com/

Set the correct permissions:

sudo chown -R www-data:www-data /var/www/newsite.com
sudo chmod -R 755 /var/www/newsite.com

Create and set permissions for the new log directory:

sudo mkdir /var/log/apache2/newsite.com
sudo chown www-data:www-data /var/log/apache2/newsite.com

Verify the virtual host configurations:

sudo apache2ctl configtest

Step 3: Migrate the Database

Export the existing database:

mysqldump -u username -p old_database_name > old_database_backup.sql

Create a new MySQL user for the new website:

mysql -u root -p
CREATE USER 'new_wp_user'@'localhost' IDENTIFIED BY 'new_password';
CREATE DATABASE new_database_name;
GRANT ALL PRIVILEGES ON new_database_name.* TO 'new_wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Import the backup into the new database:

mysql -u new_wp_user -p new_database_name < old_database_backup.sql

Step 4: Update wp-config.php

Edit wp-config.php in the new site directory, updating the MySQL settings and URLs:

define('DB_NAME', 'new_database_name');
define('DB_USER', 'new_wp_user');
define('DB_PASSWORD', 'new_password');
define('WP_HOME','http://newsite.com');
define('WP_SITEURL','http://newsite.com');

Step 5: Finalizing the Migration

Access your new domain in a browser. If the layout seems off, don’t worry. Log in to the dashboard and install the “Better Search Replace” plugin. Use it to search for oldsite.com and replace it with newsite.com. Make sure to uncheck “dry run” to apply the changes.

Lastly, check for any remaining references to the old site:

grep -Rl 'oldsite.com' /var/www/newsite.com/ | xargs sed -i 's/oldsite.com/newsite.com/g'

Now, your WordPress site should be fully migrated to the new domain. Remember to keep both the old and new sites operational until you’ve confirmed the migration is successful and search engines have updated their indexes.

Leave a Comment

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

Share the Post:

Related Posts

Training in Wisdom

Timothy Keller Sermons Podcast by Gospel in Life–Training in Wisdom Introduction Topic: Understanding and Applying God’s Wisdom Scripture Focus: Proverbs

Read More

2024年,如何将英文视频字幕转换为中文字幕?

2024年,如何将英文视频字幕转换为中文字幕? – 第一步下载视频 – 第二步 开启智能模式smart mode – 第三步 将字幕直接内嵌入mp4文件 第一步下载视频 推荐使用4k video downloader,每天有30个免费下载,不限制分辨率。 优点: 每日可下载30个视频,够用 2. 下载简单方便 3. 还能下载哔哩哔哩和其他平台视频,能在app内浏览,然后一键下载

Read More

Join Our Newsletter