CMS 설치 · 18 min read · Sep 11, 2025
Rocky Linux 9에 Craft CMS 설치하는 방법

Craft CMS는 웹사이트를 만들기 위한 오픈 소스 콘텐츠 관리 시스템입니다. 보안성과 확장성이 뛰어난 CMS로, 광범위한 플러그인 생태계와 고품질의 무료 및 유료 플러그인을 제공합니다. 콘텐츠 생성 및 관리 작업을 위한 직관적이고 사용자 친화적인 제어판을 갖추고 있습니다. Yii PHP 프레임워크를 기반으로 구축되었으며, Twig 템플릿 엔진이 템플릿 시스템을 지원합니다. MySQL 및 PostgreSQL 데이터베이스와 함께 작동할 수 있으며, Redis 데이터베이스를 캐싱 및 세션 저장소로 사용합니다.
이 튜토리얼에서는 Debian 12 서버에 Craft CMS를 설치하는 방법을 배웁니다. 또한 Redis를 활성화하여 함께 작동하도록 설정하고, Craft CMS를 사용하여 만든 사이트를 백업하고 복원하는 방법도 배웁니다.
전제 조건
- 최소 1GB의 RAM을 갖춘 Rocky Linux 9 서버.
- sudo 권한이 있는 비루트 사용자.
- 서버를 가리키는
craftcms.example.com과 같은 완전한 도메인 이름(FQDN). - Amazon SES 또는 Mailgun과 같은 이메일 서비스의 SMTP 계정.
- 모든 것이 업데이트되어 있어야 합니다.
$ sudo dnf update - 튜토리얼과 Craft CMS 실행에 필요한 몇 가지 필수 패키지가 필요합니다. 이 중 일부는 이미 서버에 있을 수 있습니다.
$ sudo dnf install wget curl nano unzip yum-utils policycoreutils-python-utils -y
1단계 - 방화벽 구성
첫 번째 단계는 방화벽을 구성하는 것입니다. Rocky Linux는 Firewalld 방화벽을 사용합니다. 방화벽의 상태를 확인합니다.
$ sudo firewall-cmd --state
running방화벽은 다양한 영역과 함께 작동하며, 공용 영역이 우리가 사용할 기본 영역입니다. 방화벽에서 활성화된 모든 서비스와 포트를 나열합니다.
$ sudo firewall-cmd --permanent --list-services다음과 같은 출력이 표시되어야 합니다.
cockpit dhcpv6-client sshHTTP 및 HTTPS 포트를 허용합니다.
$ sudo firewall-cmd --permanent --add-service=http
$ sudo firewall-cmd --permanent --add-service=https방화벽의 상태를 다시 확인합니다.
$ sudo firewall-cmd --permanent --list-services유사한 출력이 표시되어야 합니다.
cockpit dhcpv6-client http https ssh변경 사항을 적용하기 위해 방화벽을 다시 로드합니다.
$ sudo firewall-cmd --reload2단계 - Nginx 설치
Rocky Linux 9는 이전 버전의 Nginx를 기본으로 제공합니다. 최신 버전을 설치하려면 공식 Nginx 리포지토리를 사용해야 합니다.
파일 /etc/yum.repos.d/nginx.repo를 생성하고 편집을 위해 엽니다.
$ sudo nano /etc/yum.repos.d/nginx.repo다음 코드를 붙여넣습니다.
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true작업이 끝나면 Ctrl + X를 눌러 파일을 저장하고, 프롬프트가 나타나면 Y를 입력합니다.
Nginx를 설치합니다.
$ sudo dnf install nginx -y설치가 완료되었는지 확인합니다.
$ nginx -v
nginx version: nginx/1.24.0Nginx 서버 서비스를 활성화하고 시작합니다.
$ sudo systemctl enable nginx --now서비스 상태를 확인합니다.
$ sudo systemctl status nginx
? nginx.service - nginx - high performance web server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: disabled)
Active: active (running) since Mon 2023-12-04 14:01:19 UTC; 3s ago
Docs: http://nginx.org/en/docs/
Process: 59396 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 59397 (nginx)
Tasks: 2 (limit: 10866)
Memory: 1.9M
CPU: 10ms
CGroup: /system.slice/nginx.service
??59397 "nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf"
??59398 "nginx: worker process"3단계 - PHP 및 확장 프로그램 설치
Rocky Linux 9는 기본적으로 PHP 8.1을 제공합니다. 항상 최신 버전의 PHP를 유지하거나 여러 버전의 PHP를 설치하려면 REMI 리포지토리를 사용해야 합니다.
첫 번째 단계는 Epel 리포지토리를 가져오는 것입니다.
$ sudo dnf install epel-release -y다음으로 Remi 리포지토리를 설치합니다.
$ sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-9.rpm사용 가능한 PHP 스트림을 확인합니다.
$ dnf module list php -y
Name Stream Profiles Summary
php 8.1 common [d], devel, minimal PHP scripting language
Remi's Modular repository for Enterprise Linux 9 - x86_64
Name Stream Profiles Summary
php remi-7.4 common [d], devel, minimal PHP scripting language
php remi-8.0 common [d], devel, minimal PHP scripting language
php remi-8.1 common [d], devel, minimal PHP scripting language
php remi-8.2 common [d], devel, minimal PHP scripting language
php remi-8.3 common [d], devel, minimal PHP scripting language
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled기본 버전은 8.1입니다. 이 튜토리얼을 작성할 당시 Craft CMS는 PHP 8.2와 호환됩니다. 따라서 Remi의 PHP 8.2 리포지토리를 활성화합니다.
$ sudo dnf module reset php -y
$ sudo dnf module enable php:remi-8.2Craft CMS에 필요한 PHP 및 확장 프로그램을 설치합니다.
$ sudo dnf install php php-cli php-common php-json php-gmp php-fpm php-xmlrpc php-bcmath php-imagick php-curl php-zip php-gd php-mysql php-xml php-mbstring php-xmlrpc php-intl php-pgsql설치된 PHP 버전을 확인합니다.
$ php --version
PHP 8.2.13 (cli) (built: Nov 21 2023 09:55:59) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.2.13, Copyright (c) Zend Technologies
with Zend OPcache v8.2.13, Copyright (c), by Zend TechnologiesPHP-FPM 서비스를 활성화하고 시작합니다.
$ sudo systemctl enable php-fpm --nowPHP 서비스의 상태를 확인합니다.
$ sudo systemctl status php-fpm
? php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; preset: disabled)
Active: active (running) since Mon 2023-12-04 14:05:58 UTC; 6s ago
Main PID: 61410 (php-fpm)
Status: "Ready to handle connections"
Tasks: 6 (limit: 10866)
Memory: 16.6M
CPU: 96ms
CGroup: /system.slice/php-fpm.service
??61410 "php-fpm: master process (/etc/php-fpm.conf)"
??61411 "php-fpm: pool www"
??61412 "php-fpm: pool www"
??61413 "php-fpm: pool www"
??61414 "php-fpm: pool www"
??61415 "php-fpm: pool www"4단계 - PHP-FPM 구성
php.ini를 편집합니다.
$ sudo nano /etc/php.ini파일 업로드 크기를 설정하려면 upload_max_filesize 및 post_max_size 변수의 값을 변경합니다. 이 값은 Craft CMS에 업로드할 수 있는 파일 크기를 결정합니다. 우리의 목적을 위해 128MB로 설정합니다. 원하는 대로 설정할 수 있습니다.
$ sudo sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 128M/' /etc/php.ini
$ sudo sed -i 's/post_max_size = 8M/post_max_size = 128M/' /etc/php.ini서버 리소스 및 요구 사항에 따라 PHP의 메모리 제한을 구성합니다.
$ sudo sed -i 's/memory_limit = 128M/memory_limit = 256M/' /etc/php.ini파일 /etc/php-fpm.d/www.conf를 엽니다.
$ sudo nano /etc/php-fpm.d/www.confPHP 프로세스의 Unix 사용자/그룹을 nginx로 설정해야 합니다. 파일에서 user=www-data 및 group=www-data 줄을 찾아 nginx로 변경합니다.
...
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
; RPM: apache user chosen to provide access to the same directories as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
...파일에서 listen.owner = nobody, listen.group = nobody, listen.mode = 0660 줄을 찾아 주석을 제거한 후 다음과 같이 변경합니다.
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions. The owner
; and group can be specified either by name or by their numeric IDs.
; Default Values: user and group are set as the running user
; mode is set to 0660
listen.owner = nginx
listen.group = nginx
listen.mode = 0660Ctrl + X를 눌러 파일을 저장하고, 프롬프트가 나타나면 Y를 입력합니다.
PHP-fpm 프로세스를 재시작합니다. PHP 서비스를 재시작하기 전에 Nginx가 설치되어 있는지 확인하세요. 그렇지 않으면 nginx 그룹을 찾을 수 없어 실패합니다.
$ sudo systemctl restart php-fpmPHP 세션 디렉토리의 그룹을 Nginx로 변경합니다.
$ sudo chgrp -R nginx /var/lib/php/session5단계 - Composer 설치
Composer는 PHP의 의존성 관리자로 작동합니다. 또한 Craft CMS를 지원하는 Laravel PHP 프레임워크의 의존성 관리자가 됩니다.
Composer 설치 스크립트를 다운로드합니다.
$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"다운로드한 설치 프로그램을 확인합니다.
$ php -r "if (hash_file('sha384', 'composer-setup.php') === 'e21205b207c3ff031906575712edab6f13eb0b361f2085f1f1237b7126d785e826a450292b6cfd1d64d92e6563bbde02') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"다음과 같은 출력을 받게 됩니다.
Installer verified설치 스크립트를 실행하여 Composer의 최신 버전을 다운로드합니다.
$ php composer-setup.php설치 스크립트를 제거합니다.
$ php -r "unlink('composer-setup.php');"다운로드한 바이너리 파일을 /usr/local/bin 디렉토리로 이동합니다.
$ sudo mv composer.phar /usr/local/bin/composer설치가 완료되었는지 확인합니다.
$ composer --version
Composer version 2.6.5 2023-10-06 10:11:526단계 - PostgreSQL 설치 및 구성
Rocky Linux 9는 기본적으로 PostgreSQL 13을 제공합니다. 대신 공식 리포지토리에서 PostgreSQL 16을 사용할 것입니다.
PostgreSQL RPM 리포지토리를 설치합니다.
$ sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm내장 PostgreSQL 모듈을 비활성화합니다.
$ sudo dnf -qy module disable postgresql이제 아래 명령어를 사용하여 PostgreSQL을 설치할 수 있습니다.
$ sudo dnf install -y postgresql16-server postgresql16-contribpostgresql-contrib 패키지는 몇 가지 추가 유틸리티를 포함합니다.
버전을 확인합니다.
$ psql --version
psql (PostgreSQL) 16.1PostgreSQL 데이터베이스를 초기화합니다.
$ sudo /usr/pgsql-16/bin/postgresql-16-setup initdb
Initializing database ... OKPostgreSQL 서비스를 활성화합니다.
$ sudo systemctl enable postgresql-16PostgreSQL 서비스를 시작합니다.
$ sudo systemctl start postgresql-16PostgreSQL 서비스의 상태를 확인합니다.
$ sudo systemctl status postgresql-16
? postgresql-16.service - PostgreSQL 16 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-16.service; enabled; preset: disabled)
Active: active (running) since Mon 2023-12-04 22:28:34 UTC; 2s ago
Docs: https://www.postgresql.org/docs/16/static/
Process: 72143 ExecStartPre=/usr/pgsql-16/bin/postgresql-16-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 72148 (postgres)
Tasks: 7 (limit: 10866)
Memory: 17.4M
CPU: 45ms
CGroup: /system.slice/postgresql-16.service
??72148 /usr/pgsql-16/bin/postgres -D /var/lib/pgsql/16/data/
??72149 "postgres: logger "
??72150 "postgres: checkpointer "
??72151 "postgres: background writer "
??72153 "postgres: walwriter "
??72154 "postgres: autovacuum launcher "
??72155 "postgres: logical replication launcher "
Dec 04 22:28:33 craftcms.nspeaks.com systemd[1]: Starting PostgreSQL 16 database server...
Dec 04 22:28:33 craftcms.nspeaks.com postgres[72148]: 2023-12-04 22:28:33.999 UTC [72148] LOG: redirecting log output to logging collector process
Dec 04 22:28:33 craftcms.nspeaks.com postgres[72148]: 2023-12-04 22:28:33.999 UTC [72148] HINT: Future log output will appear in directory "log".
Dec 04 22:28:34 craftcms.nspeaks.com systemd[1]: Started PostgreSQL 16 database server.서비스가 기본적으로 활성화되고 실행되고 있음을 확인할 수 있습니다.
PostgreSQL 셸을 실행합니다.
$ sudo -i -u postgres psqlCraft CMS 데이터베이스를 생성합니다.
postgres=# CREATE DATABASE craftcms;Craft CMS 사용자를 생성하고 강력한 비밀번호를 선택합니다.
postgres-# CREATE USER craftuser WITH PASSWORD 'Your_Password';데이터베이스 소유자를 Craft CMS 사용자로 변경합니다.
postgres-# ALTER DATABASE craftcms OWNER TO craftuser;Craft CMS 사용자에게 데이터베이스에 대한 모든 권한을 부여합니다.
postgres-# GRANT ALL PRIVILEGES ON DATABASE craftcms TO craftuser;셸을 종료합니다.
postgres-# \q자격 증명이 작동하는지 확인합니다.
$ psql --username craftuser --password --host localhost craftcms
Password:
psql (16.1)
Type "help" for help.
craftcms=>셸을 종료하려면 \q를 입력합니다.
7단계 - Redis 설치 및 구성
Rocky Linux 9는 기본적으로 Redis 6.2를 제공합니다. 그러나 Redis 7.0을 사용할 것이며, Remi 리포지토리를 사용하여 설치할 것입니다.
PHP를 설치할 때 Remi 리포지토리를 설치했으므로 이 부분은 건너뛸 수 있습니다. 사용 가능한 Redis 모듈을 나열합니다.
$ sudo dnf module list redis
Rocky Linux 9 - AppStream
Name Stream Profiles Summary
redis 7 common [d] Redis persistent key-value database
Remi's Modular repository for Enterprise Linux 9 - x86_64
Name Stream Profiles Summary
redis remi-5.0 common [d] Redis persistent key-value database
redis remi-6.0 common [d] Redis persistent key-value database
redis remi-6.2 common [d] Redis persistent key-value database
redis remi-7.0 common [d] Redis persistent key-value database
redis remi-7.2 common [d] Redis persistent key-value database
Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled최신 Redis 7.2 모듈을 활성화합니다.
$ sudo dnf module enable -y redis:remi-7.2Redis를 설치합니다.
$ sudo dnf install redis버전을 확인합니다.
$ redis-server --version
Redis server v=7.2.3 sha=00000000:0 malloc=jemalloc-5.3.0 bits=64 build=7bd3173e4e30c3e4Redis 서비스를 활성화합니다.
$ sudo systemctl enable redisRedis 서비스를 시작합니다.
$ sudo systemctl start redis서비스 상태를 확인합니다.
$ sudo systemctl status redis
? redis.service - Redis persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; preset: disabled)
Drop-In: /etc/systemd/system/redis.service.d
??limit.conf
Active: active (running) since Mon 2023-12-04 22:36:25 UTC; 1min 32s ago
Main PID: 72877 (redis-server)
Status: "Ready to accept connections"
Tasks: 5 (limit: 10866)
Memory: 7.5M
CPU: 176ms
CGroup: /system.slice/redis.service
??72877 "/usr/bin/redis-server 127.0.0.1:6379"
Dec 04 22:36:25 craftcms.nspeaks.com systemd[1]: Starting Redis persistent key-value database...
Dec 04 22:36:25 craftcms.nspeaks.com systemd[1]: Started Redis persistent key-value database.다음 단계는 Redis 서버에 인증을 추가하는 것입니다. Redis v6.0부터 인증을 추가하는 가장 좋은 방법은 ACL(Access Control Lists)을 사용하는 것입니다. /etc/redis/redis.conf 파일을 편집하기 위해 엽니다.
$ sudo nano /etc/redis/redis.conf# aclfile /etc/redis/users.acl 항목을 찾아 해시(#)를 제거하여 주석을 해제합니다.
aclfile /etc/redis/users.aclCtrl + X를 눌러 파일을 저장하고, 프롬프트가 나타나면 Y를 입력합니다.
다음으로 /etc/redis/users.acl 파일을 생성하고 편집을 위해 엽니다.
$ sudo nano /etc/redis/users.acl다음 줄을 추가합니다.
user navjot on +@all ~* >yourpasswordCtrl + X를 눌러 파일을 저장하고, 프롬프트가 나타나면 Y를 입력합니다.
변경 사항을 적용하기 위해 Redis 서버를 재시작합니다.
$ sudo systemctl restart redisRedis 셸을 엽니다.
$ redis-cliPING 명령을 사용합니다. 인증 오류가 발생합니다.
127.0.0.1:6379> PING
(error) NOAUTH Authentication required.AUTH 명령을 사용하여 로그인합니다.
127.0.0.1:6379> AUTH navjot yourpassword
OK다시 PING 명령을 사용합니다.
127.0.0.1:6379> PING
OK셸을 종료합니다.
127.0.0.1:6379> exitPHP Redis 확장 프로그램도 설치해야 합니다.
$ sudo apt install php-redis8단계 - Craft CMS 설치
Craft CMS를 설치하기 전에 다음 명령어를 사용하여 실행을 위한 모든 서버 요구 사항을 충족하는지 확인할 수 있습니다.
$ curl -Lsf https://raw.githubusercontent.com/craftcms/server-check/HEAD/check.sh | bash다음과 같은 출력을 받게 됩니다.
Running Craft Server Check…
Craft CMS Requirement Checker
This script checks if your web server configuration meets the requirements for running a Craft CMS installation.
It checks if the server is running the right version of PHP, if appropriate PHP extensions have been loaded,
and if php.ini file settings are correct.
Results:
--------
PHP 8.2+: OK
BCMath extension: OK
ctype extension: OK
cURL extension: OK
DOM extension: OK
Fileinfo extension: OK
GD extension or ImageMagick extension: OK
iconv extension: OK
Intl extension: OK
JSON extension: OK
Multibyte String extension (with Function Overloading disabled): OK
OPcache extension (with save_comments): OK
OpenSSL extension: OK
PCRE extension (with UTF-8 support): OK
PDO extension: OK
Reflection extension: OK
SPL extension: OK
Zip extension: OK
ignore_user_abort(): OK
password_hash(): OK
proc_close(): OK
proc_get_status(): OK
proc_open(): OK
proc_terminate(): OK
allow_url_fopen: OK
ini_set calls: OK
Memory Limit: OK
------------------------------------------
Errors: 0 Warnings: 0 Total checks: 27모든 것이 괜찮다면 진행할 수 있습니다. 웹 루트 디렉토리를 생성합니다.
$ sudo mkdir /var/www/html/craftcms -p현재 로그인한 사용자를 이 디렉토리의 소유자로 설정합니다.
$ sudo chown -R $USER:$USER /var/www/html/craftcms디렉토리로 이동합니다.
$ cd /var/www/html/craftcmsComposer를 사용하여 Craft CMS를 다운로드하고 설치합니다. 명령어 끝의 점(.)은 현재 디렉토리에서 설치가 수행되어야 함을 의미합니다.
$ composer create-project craftcms/craft .설치 중에 데이터베이스, 관리자 계정, 사이트 URL 및 언어에 대한 여러 세부정보를 요청받게 됩니다. 아래와 같이 표시됩니다.
> @php craft setup/welcome
______ .______ ___ _______ .___________.
/ || _ \ / \ | ____|| |
| ,----'| |_) | / ^ \ | |__ `---| |----`
| | | / / /_\ \ | __| | |
| `----.| |\ \----./ _____ \ | | | |
\______|| _| `._____/__/ \__\ |__| |__|
A N E W I N S T A L L
______ .___ ___. _______.
/ || \/ | / |
| ,----'| \ / | | (----`
| | | |\/| | \ \
| `----.| | | | .----) |
\______||__| |__| |_______|
Generating an application ID ... done (CraftCMS--923f03f1-9bea-4c3d-a7ca-1466645ce75d)
Generating a security key ... done (iMdcUi6wQyf9MshEda__vZcCwILbclxz)
Welcome to Craft CMS!
Are you ready to begin the setup? (yes|no) [no]:yes
Which database driver are you using? (mysql or pgsql) [mysql] pgsql
Database server name or IP address: [127.0.0.1]
Database port: [5432]
Database username: [root] craftuser
Database password:
Database name: craftcms
Database table prefix:
Testing database credentials ... success!
Using default schema "public".
Saving database credentials to your .env file ... done
Install Craft now? (yes|no) [yes]:yes
Username: [admin] navjot
Email: [email protected]
Password:
Confirm:
Site name: Howtoforge Tutorials
Site URL: https://craftcms.example.com
Site language: [en-US]
*** installing CraftRedis를 Craft CMS와 함께 작동하게 만들기
yiisoft/yii2-redis 패키지를 설치합니다.
$ composer require --prefer-dist yiisoft/yii2-redis:"~2.0.0"/var/www/html/craftcms/config/app.php 파일을 편집하기 위해 엽니다.
$ nano config/app.php다음 내용을 볼 수 있습니다.
use craft\helpers\App;
return [
'id' => App::env('CRAFT_APP_ID') ?: 'CraftCMS',
];다음과 같이 변경합니다.
use craft\helpers\App;
return [
'id' => App::env('CRAFT_APP_ID') ?: 'CraftCMS',
'components' => [
'cache' => function() {
$config = [
'class' => yii\redis\Cache::class,
'keyPrefix' => Craft::$app->id,
'defaultDuration' => Craft::$app->config->general->cacheDuration,
// Full Redis connection details:
'redis' => [
'hostname' => App::env('REDIS_HOSTNAME') ?: 'localhost',
'port' => 6379,
'username' => App::env('REDIS_USERNAME') ?: null,
'password' => App::env('REDIS_PASSWORD') ?: null,
],
];
return Craft::createObject($config);
},
],
];Ctrl + X를 눌러 파일을 저장하고, 프롬프트가 나타나면 Y를 입력합니다. 이렇게 하면 Craft CMS의 캐시 저장소로 Redis가 활성화됩니다. PHP 세션 데이터, 작업 큐 및 뮤텍스 드라이버로 Redis를 사용할 수도 있습니다. 이에 대한 구성은 Craft CMS 문서에서 확인할 수 있습니다.
.env 파일에 Redis 구성을 추가해야 합니다.
$ nano .env파일 끝에 다음 코드를 추가합니다.
REDIS_HOSTNAME=localhost
REDIS_USERNAME=navjot
REDIS_PASSWORD=yourpassword위와 같이 옵션을 선택합니다. 작업이 끝나면 디렉토리의 그룹을 nginx로 변경합니다. 이렇게 하면 현재 로그인한 사용자와 Nginx가 모두 Craft CMS에 접근할 수 있습니다.
$ sudo chgrp -R nginx /var/www/html/craftcmsnginx 그룹에 디렉토리에 대한 쓰기 권한을 부여합니다.
$ sudo chmod -R g+w /var/www/html/craftcms이후에는 다시 권한을 변경할 필요가 없으며, 루트 권한 없이 모든 작업을 수행할 수 있습니다.
9단계 - SSL 설치
SSL 인증서를 생성하기 위해 Certbot을 설치해야 합니다. 이를 위해 Snapd 패키지 설치 관리자를 사용할 것입니다. Rocky Linux는 기본적으로 Snapd를 제공하지 않으므로 Snapd 설치 관리자를 설치합니다. EPEL(Extra Packages for Enterprise Linux) 리포지토리가 필요하지만, 3단계에서 이미 설치했으므로 바로 진행할 수 있습니다.
Snapd를 설치합니다.
$ sudo dnf install -y snapdSnap 서비스를 활성화하고 시작합니다.
$ sudo systemctl enable snapd --nowSnap core 패키지를 설치하고 Snapd 버전이 최신인지 확인합니다.
$ sudo snap install core && sudo snap refresh coreSnapd가 작동하도록 필요한 링크를 생성합니다.
$ sudo ln -s /var/lib/snapd/snap /snap
$ echo 'export PATH=$PATH:/var/lib/snapd/snap/bin' | sudo tee -a /etc/profile.d/snapd.shCertbot을 설치합니다.
$ sudo snap install --classic certbotCertbot 명령이 /usr/bin 디렉토리에서 실행될 수 있도록 심볼릭 링크를 생성합니다.
$ sudo ln -s /snap/bin/certbot /usr/bin/certbotCertbot이 제대로 작동하는지 확인합니다.
$ certbot --version
certbot 2.7.4다음 명령어를 실행하여 SSL 인증서를 생성합니다.
$ sudo certbot certonly --nginx --agree-tos --no-eff-email --staple-ocsp --preferred-challenges http -m [email protected] -d craftcms.example.com위 명령어는 서버의 /etc/letsencrypt/live/craftcms.example.com 디렉토리에 인증서를 다운로드합니다.
Diffie-Hellman 그룹 인증서를 생성합니다.
$ sudo openssl dhparam -dsaparam -out /etc/ssl/certs/dhparam.pem 4096Certbot 갱신 스케줄러 서비스를 확인합니다.
$ sudo systemctl list-timersnext 항목에서 snap.certbot.renew.service가 실행될 예정입니다.
NEXT LEFT LAST PASSED UNIT ACTIVATES
---------------------------------------------------------------------------------------------------------------------------
Mon 2023-12-04 23:38:47 UTC 18min left Mon 2023-12-04 22:19:02 UTC 1h 0min ago dnf-makecache.timer dnf-makecache.service
Tue 2023-12-05 00:00:00 UTC 40min left - - logrotate.timer logrotate.service
Tue 2023-12-05 09:36:00 UTC 10h left - - snap.certbot.renew.timer snap.certbot.renew.serviceSSL 갱신이 잘 작동하는지 확인하기 위해 드라이런을 수행합니다.
$ sudo certbot renew --dry-run오류가 없으면 모든 준비가 완료된 것입니다. 인증서는 자동으로 갱신됩니다.
10단계 - SELinux 구성
Craft CMS의 파일 보안 컨텍스트를 변경합니다.
$ sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/craftcms(/.*)?"정책을 적용합니다.
$ sudo restorecon -Rv /var/www/html/craftcms/Nginx가 PostgreSQL에 접근할 수 있도록 허용하는 정책을 적용합니다.
$ sudo setsebool -P httpd_can_network_connect_db 1외부 호스트에 대한 연결을 허용하는 정책을 적용합니다.
$ sudo setsebool -P httpd_can_network_connect 1MariaDB 10.11을 사용할 경우, SELinux가 PHP-FPM이 MariaDB에 연결하는 것을 차단하는 또 다른 문제가 발생할 수 있습니다. 이는 SELinux 모듈을 설치하여 해결할 수 있습니다. 첫 번째 단계는 type enforcement 파일을 만드는 것입니다.
홈 디렉토리에 my-phpfpm.te 파일을 생성하고 편집을 위해 엽니다.
$ cd ~
$ nano my-phpfpm.te다음 코드를 붙여넣습니다.
module my-phpfpm 1.0;
require {
type unconfined_service_t;
type httpd_t;
type httpd_sys_content_t;
class dir write;
class unix_stream_socket connectto;
}
#============= httpd_t ==============
#!!!! This avc is allowed in the current policy
allow httpd_t httpd_sys_content_t:dir write;
#!!!! This avc is allowed in the current policy
allow httpd_t unconfined_service_t:unix_stream_socket connectto;Ctrl + X를 눌러 파일을 저장하고, 프롬프트가 나타나면 Y를 입력합니다.
다음 단계는 다음 명령어를 사용하여 정책 모듈로 변환하는 것입니다. 명령어의 파일 이름을 수정하지 않도록 주의하세요. 모듈 이름은 my-phpfpm이며, 파일 이름도 동일해야 합니다.
$ sudo checkmodule -M -m -o my-phpfpm.mod my-phpfpm.te다음으로 정책 모듈을 컴파일하여 정책 패키지를 생성합니다.
$ sudo semodule_package -o my-phpfpm.pp -m my-phpfpm.mod마지막 단계는 semodule 명령을 사용하여 정책 패키지를 로드하는 것입니다. 이 명령은 사용될 정책을 설치합니다.
$ sudo semodule -i my-phpfpm.pp11단계 - Nginx 구성
파일 /etc/nginx/nginx.conf를 편집하기 위해 엽니다.
$ sudo nano /etc/nginx/nginx.confinclude /etc/nginx/conf.d/*.conf; 줄 앞에 다음 줄을 추가합니다.
server_names_hash_bucket_size 64;Ctrl + X를 눌러 파일을 저장하고, 프롬프트가 나타나면 Y를 입력합니다.
파일 /etc/nginx/conf.d/craftcms.conf를 생성하고 편집을 위해 엽니다.
$ sudo nano /etc/nginx/conf.d/craftcms.conf다음 코드를 붙여넣습니다. craftcms.example.com을 자신의 도메인 이름으로 바꾸십시오. client_max_body_size의 값이 128MB로 설정되어 있는지 확인합니다. 이는 PHP를 구성할 때 Craft CMS에 대해 설정한 값입니다.
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name craftcms.example.com;
root /var/www/html/craftcms/web;
index index.php;
client_max_body_size 128M;
access_log /var/log/nginx/craftcms.access.log;
error_log /var/log/nginx/craftcms.error.log;
ssl_certificate /etc/letsencrypt/live/craftcms.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/craftcms.example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/craftcms.example.com/chain.pem;
ssl_session_timeout 5m;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;
ssl_stapling on;
ssl_stapling_verify on;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
location / {
try_files $uri/index.html $uri $uri/ /index.php?$query_string;
}
location ~ [^/]
.php(/|$) {
try_files $uri $uri/ /index.php?$query_string;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_keep_conn on;
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTP_PROXY "";
}
}
# enforce HTTPS
server {
listen 80;
listen [::]:80;
server_name craftcms.example.com;
return 301 https://$host$request_uri;
}Ctrl + X를 눌러 파일을 저장하고, 프롬프트가 나타나면 Y를 입력합니다.
Nginx 구성을 확인합니다.
$ sudo nginx -tNginx 서버를 재시작합니다.
$ sudo systemctl restart nginx12단계 - Craft CMS 접근
브라우저에서 URL https://craftcms.example.com을 열면 다음 페이지로 이동합니다.

관리 페이지에 접근하려면 URL https://craftcms.example.com/admin을 방문하면 로그인 페이지로 이동합니다.

관리 자격 증명을 입력하고 로그인 버튼을 클릭하여 로그인합니다. 다음 대시보드로 이동합니다.

이제 Craft CMS를 사용하여 웹사이트를 구축할 수 있습니다.
13단계 - Craft CMS 백업 및 복원
관리 패널 내에서 관리 대시보드 >> 유틸리티 >> 데이터베이스 백업을 방문하여 Craft CMS의 데이터베이스를 백업할 수 있습니다.

백업 버튼을 클릭하여 데이터베이스 백업을 다운로드합니다. 터미널을 사용하여 백업을 생성할 수도 있습니다. 다음 명령어를 실행하여 백업을 생성합니다. 프롬프트가 나타나면 비밀번호를 입력합니다.
$ mysqldump -u craftcmsuser -p craftcms > ~/craftcms.database.sqlCraft CMS 명령줄 유틸리티를 사용하여 데이터베이스 백업을 생성할 수도 있습니다. 이 유틸리티의 장점은 데이터베이스 자격 증명을 전달할 필요가 없다는 것입니다. Craft CMS 명령 콘솔 유틸리티에 대한 자세한 내용은 여기에서 확인하세요.
$ cd /var/www/html/craftcms
$ php craft db/backup ~/
Backing up the database ... done
Backup file: /home/navjot/howtoforge-tutorials--2023-12-03-065138--v4.5.11.1.sql (200.019 KB)위 명령어에서 위치를 지정하지 않으면 백업 파일은 /var/www/html/craftcms/storage/backups 디렉토리에 작성됩니다.
파일을 백업하려면 /var/www/html/craftcms 폴더 전체를 복사하여 저장합니다.
$ cd /var/www/html
$ tar -zcf ~/craftcms.tar.gz craftcms새 서버에 복원하려면 파일을 /var/www/html 폴더에 추출합니다.
$ tar -xzf craftcms.tar.gz -C /var/www/html/새 서버에서 동일한 자격 증명으로 데이터베이스를 생성하고 다음 명령어를 사용하여 데이터베이스를 복원합니다. 프롬프트가 나타나면 비밀번호를 입력합니다.
$ mysqlimport -u craftcmsuser -p craftcms craftcms.database.sql14단계 - Craft CMS 업데이트
Craft CMS를 업데이트하는 방법은 두 가지가 있습니다. 하나는 관리 패널 내에서입니다. 업데이트가 가능할 때 알림을 받게 됩니다. 알림을 클릭하여 업그레이드합니다. Craft CMS는 업데이트를 수행하기 전에 자동으로 데이터베이스를 백업합니다.
터미널을 통해 업데이트할 수도 있습니다.
사용 가능한 모든 업데이트를 확인하려면 다음 명령어를 실행합니다.
$ cd /var/www/html/craftcms/
$ php craft update업데이트가 가능하면 다음 명령어를 실행하여 적용합니다.
$ php craft update all결론
이로써 Debian 12 서버에 Craft CMS 소프트웨어를 설치하는 방법에 대한 튜토리얼이 마무리됩니다. 질문이 있으시면 아래 댓글로 남겨주세요.
새 게시물을 받은 편지함에서 받기
스팸은 없습니다. 언제든지 구독 해지 가능합니다.