인기 워드프레스 백업 플러그인 UpdraftPlus를 사용하여 백업을 시도할 때 PHP Fatal error (Error) has occurred. Error Message: Undefined constant "DB_HOST" 오류가 발생하면서 백업에 실패하는 현상을 경험했습니다. Undefined constant "DB_HOST" 오류는 DB_HOST가 정의되지 않은 경우에 발생합니다.
워드프레스: PHP Fatal error (Error) has occurred. Error Message: Undefined constant "DB_HOST" 에러
지난주 국내호스팅 중 하나인 나우호스팅의 특정 서버에 디도스 공격이 발생하여 서버가 변경되었습니다.
나우호스팅: 일부 서버 디도스 공격으로 인한 서버 IP 주소 변경 - 워드프레스 정보꾸러미
국내 웹호스팅 업체 중 하나인 나우호스팅에서 운영하는 특정 서버에 대한 디도스 공격으로 인해 지난 4월 19일 IDC에서 서버가 차단되는 사태가 두 차례 발생하여 자체 서버실에서 서버를 복구
www.thewordcracker.com
해당 서버에 호스팅 중인 사이트가 서버 변경 후에 UpdraftPlus를 사용하여 데이터베이스(DB) 백업을 시도하니 오류가 발생하는 문제가 발생했습니다.
UpdraftPlus 플러그인을 사용하여 데이터베이스(DB)와 파일을 백업할 수 있습니다.
UpdraftPlus는 무료 버전과 유료 버전이 있으며, 보통은 무료 버전으로 충분하지만 멀티사이트를 백업하는 경우에는 프리미엄 버전을 사용할 수 있습니다.
UpdraftPlus 워드프레스 백업 플러그인 무료 버전 vs. 프리미엄 버전 - 워드프레스 정보꾸러미
UpdraftPlus는 워드프레스 사이트를 백업/복원할 수 있는 인기 플러그인입니다. 이 플러그인은 현재 300만 개가 넘는 사이트에 설치되어 사용되고 있습니다. UpdraftPlus 워드프레스 백업 플러그인은
www.thewordcracker.com
나우호스팅에서 서버 변경 후에 UpdraftPlus 플러그인을 사용하여 백업을 시도하니 에러가 발생했습니다.
An error condition has occurred for the first time during this job 로그 메시지가 표시되면서 로그 파일을 다운로드할 수 있는 링크가 표시되었습니다.
Download most recently modified log file을 다운로드하여 살펴보니 다음과 같은 로그를 확인할 수 있었습니다.
0000.000 (0) Opened log file at time: Sun, 23 Apr 2023 23:18:05 +0000 on https://www.example.co.kr
0000.001 (0) UpdraftPlus WordPress backup plugin (https://updraftplus.com): 1.23.3 WP: 6.2 PHP: 8.0.19RC1 (cgi-fcgi, Linux localhost.localdomain 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64) MySQL: 10.4.22-MariaDB (max packet size=33554432) WPLANG: ko_KR Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.1e-fips mod_fcgid/2.3.9 PHP/5.4.45 safe_mode: 0 max_execution_time: 900 memory_limit: 512M (used: 57.1M | 60.5M) multisite: N openssl: OpenSSL 1.0.2k 26 Jan 2017 mcrypt: N LANG: ZipArchive::addFile: Y
0000.001 (0) Free space on disk containing Updraft's temporary directory: 2146525.7 MB
0000.002 (0) Tasks: Backup files: 0 (schedule: manual) Backup DB: 1 (schedule: manual)
0000.004 (0) Requesting semaphore lock (d) (apparently not via scheduler)
0000.004 (0) Semaphore (d, 10a_options) was stuck, set lock time to 2023-04-23 23:18:05
0000.005 (0) Semaphore (d, 10a_options) reset to 1
0000.005 (0) Set semaphore last lock (d) time to 2023-04-23 23:18:05
0000.006 (0) Semaphore lock (d) complete
0000.007 (0) Backup run: resumption=0, nonce=4fb732879f87, file_nonce=4fb732879f87 begun at=1682291885 (0s ago), job type=backup
0000.008 (0) Scheduling a resumption (1) after 300 seconds (1682292185) in case this run gets aborted
0000.017 (0) This backup run is not intended for files - skipping
0000.018 (0) Beginning creation of database dump (WordPress DB)
0000.018 (0) PHP Fatal error (Error) has occurred. Error Message: Undefined constant "DB_HOST" (Code: 0, line 1583 in /home/web/example.co.kr/public_html/wp-content/plugins/updraftplus/backup.php)
0000.019 (0) An error condition has occurred for the first time during this job
위에서 핵심적인 부분은 [**PHP Fatal error (Error) has occurred. Error Message: Undefined constant "DB_HOST"**]인 것 같습니다.
"DB_HOST"가 정의되지 않았다는 의미입니다.
[**/wp-content/plugins/updraftplus/backup.php**] 파일의 1583 라인을 체크해 보면 다음과 같습니다.
서버가 바뀌면서 DB_HOST가 변경되었을 수 있습니다. 혹은 어떤 이유로 [**wp-config.php**] 파일에서 DB_HOST 라인이 삭제되었을 수 있습니다.
저는 살펴보니 [**wp-config.php**] 파일에서 DB_HOST 라인이 누락되어 있었습니다. 그래서 다음 라인을 구성 파일에 추가했습니다.
/** Database hostname */
define( 'DB_HOST', 'localhost' );
카페24, 블루호스트, 클라우드웨이즈 등 대부분의 웹호스팅에서 DB_HOST는 localhost입니다.
위의 라인을 [**wp-config.php**] 파일에 추가하니 UpdraftPlus에서 디비를 에러 없이 백업했습니다. [**wp-config.php**] 파일을 수정하려면 FTP에 접속해야 합니다.
워드프레스에서 wp-config.php / htaccess 파일 수정하기
워드프레스를 이용하다 보면 간혹 wp-config.php 파일이나 .htaccess 파일을 수정해야 하는 상황이 종종 발생합니다. wp-config.php 또는 .htaccess 파일은 FTP/sFTP를 통해 서버에 접속하여 수정할 수 있습니다
avada.tistory.com
FTP 접속 방법을 모르는 경우 웹호스팅 업체에 연락하면 도움을 받을 수 있을 것입니다.
참고
https://avada.tistory.com/2982
클라우드웨이즈: 워드프레스 메모리 제한 (WP Memory Limit) 설정하기
클라우드웨이즈에서는 서버 레벨에서 PHP 메모리 제한 크기를 비롯하여 PHP ini 설정값을 지정할 수 있습니다. 하지만 PHP Memory Limit 값을 조정해도 워드프레스 메모리 제한(WP Memory Limit) 크기는 늘
avada.tistory.com
https://avada.tistory.com/2974
워드프레스 뉴스페이퍼 테마 라이선스를 다른 사이트에 적용하는 방법
워드프레스 유료 테마를 사용하다가 다른 사이트에 해당 테마를 적용해야 하는 경우가 있습니다. 아바다 테마 등 Themeforest 테마의 경우 1개 사이트에 사용할 수 있으므로 추가 사이트에 적용하
avada.tistory.com
https://avada.tistory.com/2986
워드프레스 WPML 다국어 플러그인: 페이지와 글을 번역하는 방법
워드프레스에서 영어, 일본어, 중국어 등 다국어 사이트를 구축할 때 WPML 플러그인이 많이 사용됩니다. WPML 플러그인을 사용하면 언어 간 연동이 용이하며 원문 콘텐츠를 쉽게 각국 언어로 번역
avada.tistory.com