Magento 설치 · 16 min read · Oct 20, 2025

우분투 22.04에 Nginx 및 Elasticsearch로 Magento 전자상거래 설치하기

Magento는 PHP로 작성된 오픈 소스 전자상거래 플랫폼입니다. 2018년에 Adobe에 인수되었으며 Adobe eCommerce라는 이름으로 알려져 있습니다. 상업용 및 클라우드 기반 제품으로도 제공됩니다. Magento를 사용하여 고용량의 전문 쇼핑 웹사이트를 만들 수 있습니다. 단일 상점 모드와 다중 상점 모드를 모두 제공합니다. 기능을 확장할 수 있는 많은 모듈이 함께 제공됩니다.

이 튜토리얼에서는 Magento 오픈 소스 커뮤니티 에디션을 설치합니다. 전문 온라인 상점을 설정하는 데 필요한 모든 기능을 제공합니다. 또한 제품 카탈로그를 검색하기 위해 Elasticsearch를 설치하고, 세션 및 파일 캐시를 위해 Redis를 설치하며, Nginx 서버를 사용하여 제공합니다.

전제 조건

  • 최소 2GB RAM이 장착된 Ubuntu 22.04 서버. 요구 사항에 따라 더 많은 RAM이 필요할 수 있습니다.
  • sudo 권한이 있는 비루트 사용자.
  • 서버의 완전한 도메인 이름(FQDN), magento.example.com
  • 모든 것이 업데이트되었는지 확인하십시오. $ sudo apt update $ sudo apt upgrade
  • 시스템에서 필요한 몇 가지 패키지. $ sudo apt install wget curl nano software-properties-common dirmngr apt-transport-https gnupg2 ca-certificates lsb-release ubuntu-keyring unzip -y 이러한 패키지 중 일부는 이미 시스템에 설치되어 있을 수 있습니다.

1단계 - 방화벽 구성

첫 번째 단계는 방화벽을 구성하는 것입니다. Ubuntu는 기본적으로 ufw(간단한 방화벽)를 제공합니다.

방화벽이 실행 중인지 확인하십시오.

$ sudo ufw status

다음과 같은 출력이 표시되어야 합니다.

Status: inactive

SSH 포트를 허용하여 방화벽이 활성화될 때 현재 연결이 끊어지지 않도록 합니다.

$ sudo ufw allow OpenSSH

HTTP 및 HTTPS 포트도 허용합니다.

$ sudo ufw allow http
$ sudo ufw allow https

방화벽을 활성화합니다.

$ sudo ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup

방화벽 상태를 다시 확인하십시오.

$ sudo ufw status

유사한 출력이 표시되어야 합니다.

Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere
80/tcp                     ALLOW       Anywhere
443                        ALLOW       Anywhere
OpenSSH (v6)               ALLOW       Anywhere (v6)
80/tcp (v6)                ALLOW       Anywhere (v6)
443 (v6)                   ALLOW       Anywhere (v6)

2단계 - PHP 및 확장 설치

Ubuntu 22.04는 다소 구식인 PHP 8.1.2 버전을 제공합니다. Ondrej의 PHP 저장소를 사용하여 최신 PHP 8.2 버전을 설치하겠습니다.

$ sudo add-apt-repository ppa:ondrej/php

다음으로 Magento에 필요한 PHP 및 확장을 설치합니다.

$ sudo apt install php8.2-fpm php8.2-mysql php8.2-bcmath php8.2-xml php8.2-zip php8.2-curl php8.2-mbstring php8.2-gd php8.2-tidy php8.2-intl php8.2-cli php8.2-soap php8.2-xsl libsodium-dev libsodium23 libssl-dev libcurl14-openssl-dev

설치를 확인합니다.

$ php --version
PHP 8.2.5 (cli) (built: Apr 14 2023 04:27:02) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.5, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.5, Copyright (c), by Zend Technologies

3단계 - Composer 설치

Composer는 PHP의 종속성 관리 도구이며 Magento 설치에 필요합니다.

다음 명령을 실행하여 Composer 바이너리를 다운로드합니다. Magento는 Composer 2.2 LTS를 필요로 하므로 명령을 수정했습니다.

$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
$ php composer-setup.php --2.2
$ php -r "unlink('composer-setup.php');"

바이너리를 /usr/local/bin 디렉토리로 이동하여 Composer를 설치합니다.

$ sudo mv composer.phar /usr/local/bin/composer

버전을 확인하여 설치를 검증합니다.

$ composer --version
Composer version 2.2.21 2023-02-15 13:07:40

4단계 - MySQL 설치

Ubuntu 22.04는 최신 버전의 MySQL을 제공합니다. 단일 명령으로 설치할 수 있습니다.

$ sudo apt install mysql-server

MySQL 버전을 확인합니다.

$ mysql --version
mysql  Ver 8.0.33-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))

이 단계는 MySQL 버전 8.0.28 이상에 필요합니다. MySQL 셸에 들어갑니다.

$ sudo mysql

루트 사용자에 대한 비밀번호를 설정하는 다음 명령을 실행합니다. 숫자, 대문자, 소문자 및 특수 문자가 혼합되어 있는지 확인하십시오.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourPassword12!';

셸을 종료합니다.

mysql> exit

MySQL 보안 설치 스크립트를 실행합니다.

$ sudo mysql_secure_installation

먼저 루트 비밀번호를 입력하라는 메시지가 표시됩니다. 입력하십시오. 다음으로 비밀번호 유효성 검사 구성 요소를 설치할 것인지 묻는 메시지가 표시됩니다. MySQL에서 사용되는 비밀번호의 강도를 확인합니다. 설치하려면 Y를 누릅니다. 다음으로 비밀번호 유효성 검사 정책의 수준을 설정하라는 메시지가 표시됩니다. 가장 강력한 2를 선택하십시오.

Securing the MySQL server deployment.

Enter password for user root:

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: Y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root.

Estimated strength of the password: 100

다음으로 루트 비밀번호를 변경하지 않겠다고 N을 입력합니다. 또한 익명 사용자를 제거하고 원격 루트 로그인을 금지하며 테스트 데이터베이스를 제거하고 권한 테이블을 다시 로드하겠다고 Y를 입력합니다.

Change the password for root ? ((Press y|Y for Yes, any other key for No) : N

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.

All done!

5단계 - MySQL 구성

MySQL 셸에 로그인합니다. 프롬프트가 표시되면 루트 비밀번호를 입력합니다.

$ sudo mysql -u root -p

Magento용 데이터베이스를 생성합니다.

mysql> CREATE DATABASE magento;

SQL 사용자 계정을 생성합니다.

mysql> CREATE USER 'magentouser'@'localhost' IDENTIFIED BY 'Your_password2';

사용자에게 데이터베이스에 대한 모든 권한을 부여합니다.

mysql> GRANT ALL PRIVILEGES ON magento.* TO 'magentouser'@'localhost';

사용자 권한을 플러시합니다.

mysql> FLUSH PRIVILEGES;

셸을 종료합니다.

mysql> exit

6단계 - Nginx 설치

Ubuntu 22.04는 이전 버전의 Nginx를 제공합니다. 최신 버전을 설치하려면 공식 Nginx 저장소를 다운로드해야 합니다.

Nginx의 서명 키를 가져옵니다.

$ curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null

Nginx의 안정적인 버전용 저장소를 추가합니다.

$ echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg arch=amd64] \
http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list

시스템 저장소를 업데이트합니다.

$ sudo apt update

Nginx를 설치합니다.

$ sudo apt install nginx

설치를 확인합니다.

$ nginx -v
nginx version: nginx/1.24.0

Nginx 서버를 시작합니다.

$ sudo systemctl start nginx

7단계 - SSL 설치

SSL 인증서를 생성하기 위해 Certbot을 설치해야 합니다. Ubuntu의 저장소를 사용하여 Certbot을 설치하거나 Snapd 도구를 사용하여 최신 버전을 가져올 수 있습니다. 우리는 Snapd 버전을 사용할 것입니다.

Ubuntu 22.04는 기본적으로 Snapd가 설치되어 있습니다. 다음 명령을 실행하여 Snapd 버전이 최신인지 확인합니다.

$ sudo snap install core && sudo snap refresh core

Certbot을 설치합니다.

$ sudo snap install --classic certbot

다음 명령을 사용하여 Certbot 명령이 /usr/bin 디렉토리에서 실행될 수 있도록 심볼릭 링크를 생성합니다.

$ sudo ln -s /snap/bin/certbot /usr/bin/certbot

다음 명령을 실행하여 SSL 인증서를 생성합니다.

$ sudo certbot certonly --nginx --agree-tos --no-eff-email --staple-ocsp --preferred-challenges http -m [email protected] -d magento.example.com

위 명령은 서버의 /etc/letsencrypt/live/magento.example.com 디렉토리에 인증서를 다운로드합니다.

Diffie-Hellman 그룹 인증서를 생성합니다.

$ sudo openssl dhparam -dsaparam -out /etc/ssl/certs/dhparam.pem 4096

Certbot 갱신 스케줄러 서비스를 확인합니다.

$ sudo systemctl list-timers

snap.certbot.renew.service가 실행될 서비스 중 하나로 표시됩니다.

NEXT                        LEFT          LAST                        PASSED        UNIT                      ACTIVATES
.....
Sun 2023-02-26 06:32:00 UTC 9h left       Sat 2023-02-25 18:04:05 UTC 2h 59min ago  snap.certbot.renew.timer  snap.certbot.renew.service
Sun 2023-02-26 06:43:20 UTC 9h left       Sat 2023-02-25 10:49:23 UTC 10h ago       apt-daily-upgrade.timer   apt-daily-upgrade.service
Sun 2023-02-26 09:00:06 UTC 11h left      Sat 2023-02-25 20:58:06 UTC 5min ago      apt-daily.timer           apt-daily.service

SSL 갱신이 잘 작동하는지 확인하기 위해 프로세스를 드라이 런합니다.

$ sudo certbot renew --dry-run

오류가 없으면 모든 준비가 완료된 것입니다. 인증서는 자동으로 갱신됩니다.

8단계 - Elasticsearch 설치

Elasticsearch는 Magento에서 제품 검색에 사용됩니다. Magento와 호환되는 버전인 Elasticsearch 7.x를 공식 저장소를 사용하여 설치합니다.

Elasticsearch의 GPG 키를 가져옵니다.

$ wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg

Elasticsearch 저장소를 추가합니다.

$ echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list

시스템의 저장소 목록을 업데이트합니다.

$ sudo apt update

Elasticsearch를 설치합니다.

$ sudo apt install elasticsearch

Elasticsearch는 많은 메모리를 사용합니다. 서버 크기에 따라 사용량을 제한해야 합니다. /etc/elasticsearch/jvm.options.d/memory.options 파일을 생성하고 편집합니다.

$ sudo nano /etc/elasticsearch/jvm.options.d/memory.options

다음 코드를 붙여넣습니다.

-Xms1g
-Xmx1g

프롬프트가 표시되면 Ctrl + X를 눌러 파일을 저장하고 Y를 입력합니다. 이는 Elasticsearch가 1GB의 RAM을 사용하도록 구성합니다. 필요에 따라 다른 값을 사용할 수 있습니다.

서비스를 시작하고 활성화합니다.

$ sudo systemctl enable elasticsearch --now

Elasticsearch가 작동하는지 확인합니다.

$ curl http://localhost:9200

다음과 같은 출력이 표시되어야 합니다.

{
  "name" : "magento",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "6yks8tZ6T4GskIwWoXuSLA",
  "version" : {
    "number" : "7.17.10",
    "build_flavor" : "default",
    "build_type" : "deb",
    "build_hash" : "fecd68e3150eda0c307ab9a9d7557f5d5fd71349",
    "build_date" : "2023-04-23T05:33:18.138275597Z",
    "build_snapshot" : false,
    "lucene_version" : "8.11.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

9단계 - Redis 서버 설치

Magento는 세션 및 캐시 저장소로 Redis를 사용합니다. 이는 완전히 선택 사항이며 데이터베이스를 세션 저장소로 사용할 수 있습니다. 그러나 Redis가 더 나은 성능을 발휘합니다. 최신 버전의 Magento는 Redis 7.0과 호환됩니다. Ubuntu는 Redis 6.0을 제공하므로 Redis 저장소를 사용하여 설치합니다.

공식 Redis GPG 키를 가져옵니다.

$ curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg

APT 저장소를 소스 목록에 추가합니다.

$ echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list

시스템 저장소 목록을 업데이트합니다.

$ sudo apt update

Redis 서버를 설치하는 명령을 실행합니다.

$ sudo apt install redis

Redis 버전을 확인합니다.

$ redis-server -v
Redis server v=7.0.11 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=3af367a78d5e21e9

다음 명령을 사용하여 서비스 연결을 확인합니다.

$ redis-cli

Redis 셸로 전환됩니다.

첫 번째 단계는 Redis 기본 사용자에 대한 비밀번호를 설정하는 것입니다. Your_Redis_Password를 선택한 강력한 비밀번호로 바꾸십시오. 비밀번호 앞에 > 문자를 붙여야 합니다.

127.0.0.1:6379> acl setuser default >Your_Redis_Password

Redis 인증을 테스트합니다.

127.0.0.1:6379> AUTH Your_Redis_Password
OK

서비스에 핑을 보냅니다.

127.0.0.1:6379> ping
PONG

exit를 입력하여 서비스를 종료합니다.

10단계 - Magento 다운로드

Magento용 웹 루트 디렉토리를 생성합니다.

$ sudo mkdir /var/www/magento -p

현재 사용자에게 Magento 디렉토리에 대한 권한을 부여합니다.

$ sudo chown $USER:$USER /var/www/magento/ -R

/var/www 디렉토리로 전환합니다.

$ cd /var/www

더 진행하기 전에 Magento 저장소에 필요한 인증 키를 가져와야 합니다. https://account.magento.com/ 웹사이트를 방문하면 Adobe ID로 로그인하라는 페이지가 표시됩니다.

Adobe ID 로그인 페이지

Adobe ID로 로그인 버튼을 클릭하여 다음 페이지로 이동합니다.

Magento Adobe 로그인 페이지

Adobe ID가 있는 경우 자격 증명을 입력하여 계속하거나 여기에서 계정을 생성할 수 있습니다. 계정을 생성하고 로그인한 후 https://marketplace.magento.com/customer/accessKeys/ URL을 열면 됩니다. 프로필을 방문하고 Access Keys 링크를 클릭하여 이 페이지에 접근할 수도 있습니다.

Adobe Magento 프로필 Access Keys 페이지

새 액세스 키 생성 버튼을 클릭하여 인증 키를 생성합니다. 식별을 위해 키에 이름을 지정합니다.

Magento Access Keys

다음 단계에서 사용할 공개 키와 비공개 키를 모두 기록해 두십시오.

Magento 프로젝트를 생성합니다.

$ composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento

저장소의 사용자 이름과 비밀번호를 입력하라는 메시지가 표시됩니다. 공개 키를 사용자 이름으로 사용하고 비공개 키를 비밀번호로 사용하십시오. Composer 구성 디렉토리에 자격 증명을 저장할 것인지 묻는 메시지가 표시됩니다. y를 입력하여 저장합니다.

Creating a "magento/project-community-edition" project at "./magento"
    Authentication required (repo.magento.com):
      Username: 53211xxxxxxxxxxxxxxxxxxxxxxxxxxx
      Password:
Do you want to store credentials for repo.magento.com in /home/navjot/.config/composer/auth.json ? [Yn] y
Installing magento/project-community-edition (2.4.6)
  - Downloading magento/project-community-edition (2.4.6)
  - Installing magento/project-community-edition (2.4.6): Extracting archive
Created project in /var/www/magento
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Lock file operations: 564 installs, 0 updates, 0 removals
  - Locking 2tvenom/cborencode (1.0.2)
  - Locking adobe-commerce/adobe-ims-metapackage (2.2.0)
...............................................

다음 명령을 실행하여 파일 권한을 설정하고 Magento 바이너리를 실행 가능하게 만듭니다. 또한 Magento 디렉토리의 소유자를 Nginx 사용자로 설정하여 웹사이트에 접근할 수 있도록 합니다.

$ cd /var/www/magento/
$ sudo find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
$ sudo find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
$ sudo chown -R :nginx .
$ sudo chmod u+x bin/magento

11단계 - Magento 설치

Magento 디렉토리에 있는지 확인합니다.

$ cd /var/www/magento

다음 명령을 실행하여 Magento를 설치합니다.

$ bin/magento setup:install \
--base-url=http://magento.example.com \
--use-secure=1 \
--base-url-secure=https://magento.example.com \
--use-secure-admin=1 \
--db-host=localhost \
--db-name=magento \
--db-user=magentouser \
--db-password=Your_password2 \
--admin-firstname=Navjot \
--admin-lastname=Singh \
--admin-email=[email protected] \
--admin-user=navjot \
--admin-password=admin_password \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1 \
--elasticsearch-host=http://127.0.0.1 \
--elasticsearch-port=9200 \
--session-save=redis \
--session-save-redis-db=0 \
--session-save-redis-password=redis_password \
--cache-backend=redis \
--cache-backend-redis-db=2 \
--cache-backend-redis-password=redis_password \
--page-cache=redis \
--page-cache-redis-db=4 \
--page-cache-redis-password=redis_password

프로세스가 완료되면 유사한 출력이 표시됩니다.

.......
[SUCCESS]: Magento installation complete.
[SUCCESS]: Magento Admin URI: /admin_19uadb
Nothing to import.

관리 패널에 접근하기 위해 필요한 관리 URI를 기록해 두십시오.

Magento 크론 작업을 생성합니다.

$ php bin/magento cron:install

크론 작업을 확인합니다.

$ crontab -l

다음과 같은 출력이 표시되어야 합니다.

#~ MAGENTO START d1957f62aa710cc367525c9ec68dd7456d4311756b5aa37d2143c4a98b25318c
* * * * * /usr/bin/php8.2 /var/www/magento/bin/magento cron:run 2>&1 | grep -v "Ran jobs by schedule" >> /var/www/magento/var/log/magento.cron.log
#~ MAGENTO END d1957f62aa710cc367525c9ec68dd7456d4311756b5aa37d2143c4a98b25318c

12단계 - PHP-FPM 구성

/etc/php/8.2/fpm/pool.d/www.conf 파일을 엽니다.

$ sudo nano /etc/php/8.2/fpm/pool.d/www.conf

PHP 프로세스의 Unix 사용자/그룹을 nginx로 설정해야 합니다. 파일에서 user=www-datagroup=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 = www-datalisten.group = www-data 줄을 찾아 nginx로 변경합니다.

; 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

파일을 저장하려면 Ctrl + X를 누르고 프롬프트가 표시되면 Y를 입력합니다.

PHP-FPM 및 PHP-CLI의 실행 시간을 180초로 늘립니다.

$ sudo sed -i 's/max_execution_time = 30/max_execution_time = 180/' /etc/php/8.2/fpm/php.ini
$ sudo sed -i 's/max_execution_time = 30/max_execution_time = 180/' /etc/php/8.2/cli/php.ini

PHP-FPM의 메모리 제한을 128MB에서 256MB로 늘립니다. 서버 크기 및 요구 사항에 따라 제한을 높일 수 있습니다.

$ sudo sed -i 's/memory_limit = 128M/memory_limit = 256M/' /etc/php/8.2/fpm/php.ini

Magento는 기본적으로 미디어 라이브러리의 파일 크기 제한을 2MB로 설정합니다. 다음 명령을 실행하여 파일 크기 제한을 25MB로 늘립니다.

$ sudo sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 25M/g' /etc/php/8.2/fpm/php.ini
$ sudo sed -i 's/post_max_size = 8M/post_max_size = 25M/g' /etc/php/8.2/fpm/php.ini

Zlib 압축을 켭니다.

$ sudo sed -i 's/zlib.output_compression = Off/zlib.output_compression = On/g' /etc/php/8.2/fpm/php.ini

PHP-FPM 서비스를 재시작합니다.

$ sudo systemctl restart php8.2-fpm

PHP 세션 디렉토리의 그룹을 Nginx로 변경합니다.

$ sudo chgrp -R nginx /var/lib/php/sessions

13단계 - Nginx 구성

/etc/nginx/nginx.conf 파일을 열어 편집합니다.

$ sudo nano /etc/nginx/nginx.conf

include /etc/nginx/conf.d/*.conf; 줄 앞에 다음 줄을 추가합니다.

server_names_hash_bucket_size  64;

파일을 저장하려면 Ctrl + X를 누르고 프롬프트가 표시되면 Y를 입력합니다.

/etc/nginx/conf.d/magento.conf 파일을 생성하고 열어 편집합니다.

$ sudo nano /etc/nginx/conf.d/magento.conf

다음 코드를 붙여넣습니다.

upstream fastcgi_backend {
  server  unix:/run/php/php8.2-fpm.sock;
}

server {
  # Redirect any http requests to https
  listen 80;
  listen [::]:80;
  server_name magento.example.com;
  return 301 https://$host$request_uri;
}

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name magento.example.com;

  set $MAGE_ROOT /var/www/magento;
  include /var/www/magento/nginx.conf.sample;
  client_max_body_size 25m;

  access_log /var/log/nginx/magento.access.log;
  error_log  /var/log/nginx/magento.error.log;

  # TLS configuration
  ssl_certificate /etc/letsencrypt/live/magento.example.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/magento.example.com/privkey.pem;
  ssl_trusted_certificate /etc/letsencrypt/live/magento.example.com/chain.pem;
  ssl_protocols TLSv1.2 TLSv1.3;

  ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-GCM-SHA384';
  ssl_prefer_server_ciphers on;
  ssl_session_cache shared:SSL:50m;
  ssl_session_timeout 1d;

  # OCSP Stapling ---
  # fetch OCSP records from URL in ssl_certificate and cache them
  ssl_stapling on;
  ssl_stapling_verify on;
  ssl_dhparam /etc/ssl/certs/dhparam.pem;
}

파일을 저장하려면 Ctrl + X를 누르고 프롬프트가 표시되면 Y를 입력합니다.

Magento는 /var/www/magento/nginx.conf.sample에 Nginx 구성 템플릿을 제공하며, 이를 구성에 포함했습니다. $MAGE_ROOT 변수는 우리가 파일에서 설정한 Magento 웹 루트 디렉토리를 가리키며 샘플 구성 파일에서 사용됩니다.

Nginx 구성 파일 구문을 확인합니다.

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Nginx 서비스를 재시작합니다.

$ sudo systemctl restart nginx

https://magento.example.com URL을 통해 Magento 웹사이트를 엽니다. 다음 페이지가 표시되어야 합니다.

Magento 홈페이지

CSS 및 JS가 로드되지 않는 경우 다음 명령을 실행합니다.

$ cd /var/www/magento
$ php bin/magento setup:static-content:deploy -f
$ php bin/magento indexer:reindex

14단계 - 이중 인증 비활성화

관리 패널에 접근하기 전에 기본적으로 활성화된 이중 인증을 비활성화해야 합니다. Magento는 설치 중에 이중 인증을 활성화하기 위해 sendmail을 통해 메일을 보내려고 하지만, 이를 구성하지 않았기 때문에 먼저 이 기능을 비활성화해야만 대시보드에 접근할 수 있습니다.

서버에 sendmail이 구성되어 있어 이메일을 보낼 수 있는 경우 이 단계를 건너뛸 수 있습니다. 이중 인증을 비활성화하려면 다음 명령을 사용하여 Magento의 두 모듈을 비활성화해야 합니다.

$ php /var/www/magento/bin/magento module:disable Magento_AdminAdobeImsTwoFactorAuth
$ php /var/www/magento/bin/magento module:disable Magento_TwoFactorAuth

클래스를 생성하기 위해 다음 명령을 실행합니다.

$ php /var/www/magento/bin/magento setup:di:compile

캐시도 정리합니다.

$ php /var/www/magento/bin/magento c:c

15단계 - 관리 포털 접근

Magento 설치 스크립트에서 제공한 URI를 사용하여 관리 포털을 열어야 합니다. 만약 이를 기록하지 않았거나 잃어버린 경우, 다음 명령을 사용하여 URI를 다시 가져올 수 있습니다.

$ php /var/www/magento/bin/magento info:adminuri
Admin URI: /admin_19uadb

브라우저에서 https://magento.example.com/admin_19uadb URL을 열면 다음 화면이 표시됩니다.

Magento 관리자 대시보드 로그인 페이지

설치 중 제공된 관리자 자격 증명을 입력하고 로그인 버튼을 클릭하여 진행합니다. 다음 화면이 표시됩니다.

Magento 관리자 대시보드

Adobe가 사용 데이터 수집을 요청하는 팝업이 표시됩니다. 진행하려면 허용하지 않음 버튼을 클릭합니다.

다음 단계는 이메일을 위한 SMTP를 구성하여 이중 인증을 다시 활성화할 수 있도록 하는 것입니다. 상점 >> 구성 메뉴를 방문합니다.

Magento 상점 >> 구성 메뉴

왼쪽에서 고급 메뉴를 확장하고 시스템 옵션을 클릭하여 이메일 설정 페이지를 엽니다.

Magento 이메일 발송 설정

전송, 호스트 및 포트 옵션 앞의 시스템 값 사용을 선택 해제합니다. 전송 드롭다운 메뉴를 클릭하고 SMTP를 선택합니다. 이 튜토리얼에서는 Amazon SES를 메일러로 사용하고 있습니다.

Magento Amazon SES 메일 설정

SMTP 호스트, 포트 587, 사용자 이름 및 비밀번호를 입력하고 AuthLOGIN으로 설정하고 SSLTLS로 설정합니다. 완료되면 구성 저장 버튼을 클릭합니다. 이제 이메일 설정을 구성했으므로 다음 단계는 상점 이메일 ID를 구성하여 테스트할 수 있도록 하는 것입니다.

같은 페이지에서 위로 스크롤하여 일반 메뉴를 확장하고 상점 이메일 주소 옵션을 선택합니다.

Magento 상점 이메일 주소 페이지

기본 발신자 이메일 필드를 선택 해제하고 상점의 이메일 ID를 입력합니다. 완료되면 구성 저장 버튼을 클릭합니다. 마찬가지로 연락처 화면을 열고 동일한 변경을 수행한 후 구성 저장 버튼을 클릭하여 완료합니다.

Magento 문의하기 이메일 설정

관리자 옵션을 변경하면 캐시에 영향을 줄 수 있으며 경고가 표시됩니다. 다음 명령을 실행하여 캐시를 수동으로 지웁니다.

$ php /var/www/magento/bin/magento c:c

이메일을 테스트하려면 상점 페이지를 방문하고 문의하기 페이지를 엽니다. https://magento.example.com/contact/ URL을 사용하여 직접 접근할 수 있습니다. 테스트 메시지를 보내고 제출 버튼을 클릭합니다. 비슷한 메일을 받을 수 있어야 합니다.

Magento 테스트 이메일

16단계 - 이중 인증 활성화 및 구성

이제 SMTP 메일러를 활성화했으므로 이중 인증을 다시 활성화할 시간입니다. 다음 명령을 실행하여 이중 인증을 활성화합니다.

$ php /var/www/magento/bin/magento module:enable Magento_AdminAdobeImsTwoFactorAuth
$ php /var/www/magento/bin/magento module:enable Magento_TwoFactorAuth

모듈의 설정을 업그레이드합니다.

$ php /var/www/magento/bin/magento setup:upgrade

클래스를 생성하기 위해 다음 명령을 실행합니다.

$ php /var/www/magento/bin/magento setup:di:compile

캐시도 정리합니다.

$ php /var/www/magento/bin/magento c:c

관리 영역에 접근할 수 없는 경우 다음 명령도 실행합니다.

정적 콘텐츠를 강제로 배포합니다.

$ php /var/www/magento/bin/magento setup:static-content:Deploy -f

파일 권한을 설정합니다.

$ cd /var/www/magento
$ sudo find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
$ sudo find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
$ sudo chown -R :nginx .

관리 포털을 방문하면 다음 화면이 표시됩니다.

Magento 2FA 구성

Google Authenticator 방법을 사용할 것입니다. 하드웨어 키가 있는 경우 사용할 수 있습니다. Google Authenticator 방법은 Authy, 1Password, Bitwarden, Microsoft Authenticator 등 모든 TOTP 앱과 호환됩니다. 진행하려면 적용 버튼을 클릭합니다.

Magento Google 2FA 구성

다음 페이지에서 2FA 앱으로 스캔할 QR 코드를 받게 됩니다. 앱에 세부 정보를 입력하고 생성된 코드를 인증 코드 필드에 복사합니다. 확인 버튼을 클릭하여 관리자 대시보드로 진행합니다.

결론

이로써 Nginx 서버와 Elasticsearch로 Ubuntu 22.04에 Magento 전자상거래 사이트를 설치하는 튜토리얼이 완료되었습니다. 질문이 있는 경우 아래 댓글로 남겨주세요.

Share: X/Twitter LinkedIn

새 게시물을 받은 편지함에서 받기

스팸은 없습니다. 언제든지 구독 해지 가능합니다.