域服务器迁移_域迁移到Unix服务器

域服务器迁移

To switch Web providers or install a new server entails the migration of all your domain’s Web pages and other files. While we won’t cover implementation and configuration of a virtual domain here, we will focus on how to transfer the files from your previous server to the new one.

要切换Web提供程序或安装新服务器,必须迁移您域的所有网页和其他文件。 虽然我们不会在此处介绍虚拟域的实现和配置,但我们将重点介绍如何将文件从您以前的服务器传输到新服务器。

为什么迁移不像看起来那么简单 (Why Migration isn’t as Simple as it Looks)

At first glance, this task may seem straightforward enough: simply download the files by FTP to your local system, and then upload them again to the new server.

乍一看,此任务似乎很简单:只需通过FTP将文件下载到本地系统,然后将其再次上传到新服务器即可。

However, this approach has several serious drawbacks:

但是,这种方法有几个严重的缺点:

  • file permissions will not be preserved

    文件权限将不会保留
  • file ownership will change

    文件所有权将改变
  • ASCII files carrying an unknown extension may be treated as binaries

    带有未知扩展名的ASCII文件可被视为二进制文件
  • the files will be down- and uploaded in uncompressed form, which wastes time, bandwidth and system resources.

    文件将以未压缩的形式下载和上传,这浪费了时间,带宽和系统资源。

If you proceed in this manner, you’ll be in for a lot of adjustment work to make everything run as it did before. This applies especially to CGI scripts where directory and file permissions are critical to ensure functionality.

如果以这种方式进行,您将需要进行大量调整工作,以使所有操作都像以前一样运行。 这尤其适用于目录和文件权限对于确保功能至关重要的CGI脚本。

轻松迁移 (Migration Made Easy)

Here’s a method that will simplify your migration and slash unnecessary work in the process.

这是一种可以简化您的迁移并削减过程中不必要工作的方法。

  1. Log in to your old server by Telnet (e.g. as user "domainowner").

    通过Telnet登录到旧服务器(例如,以“ domainowner”用户身份)。

  2. Navigate to your domain directory (e.g. :cd /usr/www/htdocs/yourdomain).

    导航到您的域目录(例如:cd /usr/www/htdocs/yourdomain )。

  3. Next, compress the files into an archive by entering the following on the command line:

    接下来,通过在命令行中输入以下内容,将文件压缩为归档文件:

    tar -cpz --same-owner -f yourdomain.tar.gz * .htaccess

    tar -cpz --same-owner -f yourdomain.tar.gz * .htaccess

  4. The "tar" command requires the following syntax: tar -function -option file  function:   c create archive  option:     p extract all protection information    z compress data with gzip    --same-owner create extracted files with the same ownership    f use archive file In our example above, the achive file "yourdomain.tar.gz" will be generated. You may chose any file name you prefer, as long as you stick to the extension ".tar.gz". The wildcard character "*" (second-last in the command above) specifies that all files, including those that reside in subdirectories, will be included in the archive. However, because this won’t include files that begin with a period, you will have to list those files explicitly. In our example this is file ".htaccess".

    “ tar”命令要求使用以下语法: tar -function -option file function: c create archive option: p extract all protection information z compress data with gzip --same-owner create extracted files with the same ownership f use archive file在上面的示例中,将生成活动文件“ yourdomain.tar.gz ”。 您可以选择任何喜欢的文件名,只要坚持使用扩展名“ .tar.gz ”即可。 通配符“ * ”(上述命令的倒数第二个)指定所有文件(包括驻留在子目录中的文件)都将包含在存档中。 但是,由于其中不包括以句点开头的文件,因此您必须明确列出这些文件。 在我们的示例中,这是文件“ .htaccess ”。

  5. Now, on the new server, you will have to configure user account "domainowner" and the directory "/usr/www/htdocs/yourdomain". Note that if the directory names on your previous server are not identical to those on your new server, you may have to modify the path variables in your CGI scripts. Hence, it’s strongly recommended that you simply clone directory names.

    现在,在新服务器上,您将必须配置用户帐户“ domainowner ”和目录“ /usr/www/htdocs/yourdomain ”。 请注意,如果先前服务器上的目录名称与新服务器上的目录名称不同,则可能必须在CGI脚本中修改路径变量。 因此,强烈建议您仅克隆目录名称。

  6. Now, to upload the archive file "yourdomain.tar.gz" to your new system. There are two possible ways to do this:

    现在,将存档文件“ yourdomain.tar.gz ”上传到新系统。 有两种方法可以做到这一点:

    • directly, by logging in to your new server and downloading the file from there using whatever FTP client is available, e.g. WU-FTP. Consult the program’s documentation to learn how to do this as we cannot cover it here.

      通过直接登录到新服务器并使用可用的任何FTP客户端(例如WU-FTP)从该服务器下载文件来直接进行操作。 请查阅程序的文档以了解如何执行此操作,因为我们无法在此处进行介绍。

      or

      要么

    • by downloading the file to your local system first, and then uploading it to the new server from there.

      首先将文件下载到本地系统,然后从那里将其上传到新服务器。

    Now, to upload the archive file "yourdomain.tar.gz" to your new system. There are two possible ways to do this:

    现在,将存档文件“ yourdomain.tar.gz ”上传到新系统。 有两种方法可以做到这一点:

  7. On the new system, log in via Telnet e.g. as user "domainowner".

    在新系统上,以用户“ domainowner”的身份通过Telnet登录。

  8. Switch into your domain directory e.g. by typing: cd /usr/www/htdocs/yourdomain

    切换到您的域目录,例如,键入: cd /usr/www/htdocs/yourdomain

  9. Next, you’ll need to unpack the archive file. Enter the command:

    接下来,您需要解压缩存档文件。 输入命令:

    tar -xz -f yourdomain.tar.gz 
     
        function:   x extract files from an archive 
        option:     z uncompress data with gzip 
                    f use archive file

There - you have now successfully duplicated the previous, familiar environment on your new system!

在那里-您现在已经在新系统上成功复制了以前熟悉的环境!

However, I'd recommend that you test the new domain setup thoroughly, especially your CGI scripts, before you launch it officially.

但是,我建议您在正式启动新域之前,对它进行彻底测试,尤其是CGI脚本。

同步系统 (Synchronize your Systems)

Should some files on your previous server have been modified or added before actual launch of your new setup, you can synchronize the two systems in the following manner:

如果在实际启动新设置之前已修改或添加了先前服务器上的某些文件,则可以通过以下方式同步两个系统:

  1. Log in via Telnet on your old server e.g. as user "domainowner".

    通过Telnet登录到旧服务器上,例如,以“ domainowner”用户身份登录。

  2. Switch to your domain directory, e.g. by entering:

    切换到您的域目录,例如,输入:

    cd /usr/www/htdocs/yourdomain

    cd /usr/www/htdocs/yourdomain

  3. List all new and modified files, using this command:

    使用此命令列出所有新文件和修改过的文件:

    /usr/bin/find -newer yourdomain.tar.gz > newerfiles.txt

    /usr/bin/find -newer yourdomain.tar.gz > newerfiles.txt

  4. This command will compare the files with the archive file you generated in Step 3 above. All new and modified files will now be listed in the file "newerfiles.txt".

    此命令会将文件与您在上面的步骤3中生成的归档文件进行比较。 现在,所有新文件和修改过的文件都将列在文件“ newerfiles.txt ”中。

  5. Edit the file "newerfiles.txt" and delete the line "." and the lines including directories, e.g.: "./graphics" You can do this in two ways. To complete the changes locally, download the file first and open your text editor (ASCII format only!). Or, to carry out the changes online, open your favorite online editor.

    编辑文件“ newerfiles.txt ”并删除“ . ”行和包含目录的行,例如:“ ./graphics ”您可以通过两种方式执行此操作。 要在本地完成更改,请先下载文件,然后打开文本编辑器(仅ASCII格式!)。 或者,要在线进行更改,请打开您喜欢的在线编辑器。

  6. Next, the new and modified files must be packed into an archive with this command:

    接下来,必须使用以下命令将新文件和修改后的文件打包到存档中:

    tar -cpz --same-owner -f yourdomain-new-files.tar.gz -T
    newerfiles.txt
    option:   T get names to extract or create from file F
  7. Now, upload the newly generated archive file, "yourdomain-new-files.tar.gz", to your new server as explained above in Step 5 above.

    现在,按照上面第5步中的说明,将新生成的存档文件“ yourdomain-new-files.tar.gz ”上传到新服务器。

  8. To unpack the archive, enter this command:

    要解压缩档案,请输入以下命令:

    tar -xz -f yourdomain-new-files.tar.gz

Congratulations! All the files on your old and your new systems have been synchronized and you can activate the migrated domain on its new hosting server.

恭喜你! 旧系统和新系统上的所有文件都已同步,您可以在新的托管服务器上激活迁移的域。

翻译自: https://www.sitepoint.com/domain-migration-unix-server/

域服务器迁移

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值