본문으로 건너뛰기

SSH로 매니지드워드프레스 서비스로 이전하려면 어떻게 하나요?

💡 요약 정리

1. 개요와 선택지

주의
  • FTP 개별 다운로드는 파일 누락 문제가 있을 수 있습니다. 가능하다면 서버 관리자에게 DATA/DB 압축 백업을 요청해 주세요.
  • 압축 파일을 확보했다면, 카페24 서버에 업로드 후 압축 해제를 진행하세요. 필요 시 압축 해제 요청을 해주시면 됩니다.

바로가기


2. SSH를 통한 이전 방법

1. 원본 서버에서 SSH 터미널 접속하기

2. DATA 압축하기

$ tar cfzv datafile.tar.gz www .htaccess
www/wp-admin/load-styles.php
www/wp-admin/erase-personal-data.php
www/wp-admin/maint/
www/wp-admin/maint/repair.php
www/wp-config-sample.php
.htaccess
........................

$ ls -al datafile.tar.gz
-rw-r--r-- 1 USERID USERID 20447707 4월 19 11:12 datafile.tar.gz
  • 위 명령은 www와 .htaccess가 존재하는 디렉터리에서 실행한 예시입니다.

3. DB 덤프하기

$ mysqldump -u USERID -p DBNAME -R > dbfile.sql
Enter password:

$ ls -al dbfile.sql
-rw-r--r-- 1 USERID USERID 1212962 4월 19 11:13 dbfile.sql
  • DBNAME은 계정명(USERID)과 다를 수 있습니다. 사용 중인 실제 데이터베이스명을 넣어 실행하세요.

4. FTP로 접속하여 다운로드 하기

원본 서버에서 FTP로 DATA/DB 파일 다운로드 예시 화면
  • 원본 서버에서 생성한 datafile.tar.gz와 dbfile.sql을 로컬 PC로 안전하게 내려받습니다.

5. 매니지드서비스 서버에 FTP로 접속하기

6. DATA 압축파일 / DB 덤프파일 업로드 하기

카페24 서버로 DATA/DB 파일 업로드 예시 화면
  • 생성한 datafile.tar.gz, dbfile.sql을 계정으로 업로드합니다.
  • 이후 단계(압축 해제, DB 임포트)는 업로드한 파일이 있는 동일 경로에서 진행하세요.

7. SSH 접근 후 압축해제 하기

$ tar zxvf datafile.tar.gz
www/wp-admin/update.php
www/wp-admin/load-styles.php
www/wp-admin/erase-personal-data.php
www/wp-admin/maint/
www/wp-admin/maint/repair.php
www/wp-config-sample.php
.htaccess
.................
  • 업로드한 datafile.tar.gz가 있는 경로에서 위 명령을 실행합니다.

8. DB 임포트 하기

## DB 패스워드 입력
$ mysql -u USERID -p USERID < dbfile.sql
Enter password:
  • 위 예시에서는 데이터베이스명이 USERID와 동일한 경우입니다. 데이터베이스명이 USERID와 다르면, 두 번째 USERID 자리에 실제 DBNAME을 사용하세요.

9. 테이블 정보 확인 하기

## mysql prompt 접근하기
$ mysql -u USERID -p DBNAME
Enter password:

## 테이블 정보 확인
MariaDB [USERID]> show tables;
+-----------------------+
| Tables_in_USERID      |
+-----------------------+
| wp_commentmeta        |
| wp_comments           |
| wp_links              |
| wp_options            |
| wp_postmeta           |
| wp_posts              |
| wp_term_relationships |
| wp_term_taxonomy      |
| wp_termmeta           |
| wp_terms              |
| wp_usermeta           |
| wp_users              |
+-----------------------+
12 rows in set (0.00 sec)
  • 접속 시 마지막 인자인 DBNAME에 실제 데이터베이스명을 넣어주세요. 출력에 표시되는 DB명은 예시이며, 사용 중인 환경에 따라 다를 수 있습니다.

10. wp-config.php 파일 수정하기

## USERID > USERID 로 이전한 경우

/** The name of the database for WordPress */
define( 'DB_NAME', 'USERID' );

/** Database username */
define( 'DB_USER', 'USERID' ); 
// /** Database password */
define( 'DB_PASSWORD', '디비패스워드' );
/** Database hostname */
define( 'DB_HOST', 'localhost' );
  • 위 예시는 DB_NAME이 USERID와 동일한 환경입니다. 실제 환경에서 DB명이 다르면 DB_NAME 값을 해당 DBNAME으로 변경하세요.

11. 소스내 절대 경로나 도메인 경로 수정하기

  • find, egrep으로 파일 내에서 기존 계정 소스 찾기
[root@husw7-0035 www]# find -type f | xargs -i grep USERID -l {}
./wp-config.php
./wp-content/debug.log

12. DB내 도메인 정보 수정 하기

① MYSQL(MARIADB) PROMPT로 접근합니다. (또는 HeidiSQL 등의 GUI 툴로 작업해도 됩니다.)

# ssh 터미널상에서 mysql prompt로 접근
$ mysql -u USERID -p DBNAME
Enter password: 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 9166791
Server version: 10.1.13-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [USERID]>

② wp_options 테이블의 siteurl, home 값을 변경할 도메인으로 update 합니다.

## USERID.mycafe24.com 에서 newdomain.com 으로 변경 하는경우 
MariaDB [USERID]> select * from wp_options where option_id<3;
+-----------+-------------+-------------------------------+----------+
| option_id | option_name | option_value                  | autoload |
+-----------+-------------+-------------------------------+----------+
|         1 | siteurl     | http://USERID.mycafe24.com/ | yes      |
|         2 | home        | http://USERID.mycafe24.com/ | yes      |
+-----------+-------------+-------------------------------+----------+
2 rows in set (0.05 sec)

MariaDB [USERID]> update wp_options set option_value='http://newdomain.com' where option_id<3 limit 2;
Query OK, 2 rows affected (0.45 sec)
Rows matched: 2  Changed: 2  Warnings: 0

MariaDB [USERID]> select * from wp_options where option_id<3;
+-----------+-------------+----------------------+----------+
| option_id | option_name | option_value         | autoload |
+-----------+-------------+----------------------+----------+
|         1 | siteurl     | http://newdomain.com | yes      |
|         2 | home        | http://newdomain.com | yes      |
+-----------+-------------+----------------------+----------+
2 rows in set (0.00 sec)

13. 브라우저로 사이트 접속 후 개발자 도구로 에러 확인하기

브라우저 개발자 도구를 이용한 에러 확인 예시 화면
  • 브라우저 개발자 도구 콘솔에서 네트워크/콘솔 오류(CORS 등)를 확인합니다.

추가 안내