Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the health-check 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/lihaoz.tplinkdns.com/wp-includes/functions.php on line 6121

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the astra 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/lihaoz.tplinkdns.com/wp-includes/functions.php on line 6121
How to Migrate WordPress to Another Domain: A Step-by-Step Guide – Barry's Island

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

VideoForge AI Implementation Details:

Python项目模块化开发指南 标准Python项目结构 对于一个模块化的Python项目,以下是一个广泛采用的标准结构^2: videoforge_ai/ # 项目根目录 ├── LICENSE # 项目许可证 ├── README.md # 项目说明文档 ├── pyproject.toml # 现代Python项目依赖管理 ├── setup.py

Read More

VideoForge AI: 自动化智能视频生成流水线

项目概述 VideoForge AI是一个端到端的自动化视频生成系统,通过人工智能将简单文本创意转化为专业质量的视频内容。系统整合大语言模型、文本转语音技术、AI图像生成和3D Photo Inpainting技术,实现从创意构思到完整视频的全自动生成流程,无需专业视频编辑技能。 核心功能: 文本到视频的全流程自动化 智能场景分解与连贯性保证 静态图像转动态2.5D视差效果视频 自动语音合成与字幕生成 定制化氛围背景音乐生成 痛点与解决方案 现有问题 专业技能壁垒:传统视频制作需要专业软件技能和创意设计经验 时间密集型:从构思到完成一个短视频通常需要数小时到数天 资源需求高:需要多种工具、素材库和硬件资源 静态内容局限性:静态图片和文字无法有效传达动态信息 我们的解决方案 VideoForge AI将整个视频制作流程简化为一个文本输入过程。用户只需提供创意描述,系统自动完成从脚本生成、画面创建到最终渲染的全部工作。通过3D

Read More

Join Our Newsletter