웹사이트 검색

Apache2로 Magento 전자 상거래 플랫폼 설치 및 Ubuntu 20.04에서 Lets Encrypt


이 페이지에서

  1. 전제 조건
  2. LAMP 서버 설치
  3. MariaDB 데이터베이스 구성
  4. 마젠토 다운로드
  5. Magento용 Apache 구성
  6. Lets Encrypt SSL로 Magento 보안
  7. Magento 웹사이트 액세스
  8. 결론

Magento는 완전한 기능을 갖춘 전자 상거래 상점을 몇 분 안에 만들 수 있는 무료 오픈 소스 전자 상거래 웹 애플리케이션입니다. PHP로 작성되었으며 강력한 기능과 유연성 및 사용자 친화적인 인터페이스를 결합합니다. 단순성과 강력한 관리자 패널로 인해 자체 호스팅 온라인 상점에서 가장 많이 사용되는 솔루션 중 하나입니다. 사이트 관리, SEO, 카탈로그 관리, 제품 및 카탈로그 브라우징, 주문 관리, 결제, 판촉 및 변환 도구 등을 포함한 다양한 기능이 함께 제공됩니다.

이 튜토리얼에서는 Ubuntu 20.04에서 Apache 및 Lets Encrypt SSL을 사용하여 Magento 전자 상거래 플랫폼을 설치하는 방법을 보여줍니다.

전제 조건

  • 4GB RAM으로 Ubuntu 20.04를 실행하는 서버.\n
  • 서버를 가리키는 유효한 도메인 이름입니다.\n
  • 서버에 루트 암호가 구성되어 있습니다.\n

램프 서버 설치

Magento는 PHP로 작성된 웹 서버에서 실행되며 MariaDB를 데이터베이스로 사용합니다. 따라서 서버에 LAMP 스택을 설치해야 합니다.

먼저 다음 명령을 사용하여 Apache 웹 서버와 MariaDB 서버를 설치합니다.

apt-get install apache2 mariadb-server mariadb-client -y

최신 버전의 Magento는 PHP 7.1.3+ 및 7.2.x와만 호환됩니다. 따라서 서버에 필요한 확장이 포함된 지원되는 PHP 버전을 설치해야 합니다.

기본적으로 Ubuntu 20.04는 PHP 버전 7.4와 함께 제공됩니다. 따라서 다른 PHP 버전을 설치하려면 시스템에 Ondrej PPA를 추가해야 합니다.

다음 명령을 사용하여 Ondrej PHP PPA를 추가할 수 있습니다.

apt-get install software-properties-common -y
add-apt-repository ppa:ondrej/php

다음으로 다음 명령을 사용하여 리포지토리를 업데이트하고 필요한 다른 확장과 함께 PHP를 설치합니다.

apt-get install php7.2 libapache2-mod-php7.2 php7.2-bcmath php7.2-common php7.2-mbstring php7.2-xmlrpc php7.2-soap php7.2-gd php7.2-xml php7.2-intl php7.2-mysql php7.2-cli php7.2-ldap php7.2-zip php7.2-curl wget curl unzip -y

완료되면 다음 단계로 진행할 수 있습니다.

MariaDB 데이터베이스 구성

기본적으로 MariaDB는 보안되지 않습니다. 따라서 MariaDB 루트 암호를 보호하고 설정하는 것이 좋습니다. 다음 명령으로 수행할 수 있습니다.

mysql_secure_installation

아래와 같이 모든 질문에 답하십시오.

Enter current password for root (enter for none): 
Set root password? [Y/n] Y
New password: 
Re-enter new password: 
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

MariaDB가 보호되면 MariaDB 셸에 로그인합니다.

mysql -u root -p

MariaDB 루트 암호를 제공한 다음 Magento에 대한 데이터베이스 및 사용자를 만듭니다.

MariaDB [(none)]> CREATE DATABASE magentodb;
MariaDB [(none)]> CREATE USER 'magento'@'localhost' IDENTIFIED BY 'password';

다음으로 다음 명령을 사용하여 Magento 데이터베이스에 모든 권한을 부여합니다.

MariaDB [(none)]> GRANT ALL ON magentodb.* TO 'magento'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

다음으로 다음 명령을 사용하여 권한을 플러시하고 MariaDB 셸을 종료합니다.

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

완료되면 다음 단계로 진행할 수 있습니다.

마 젠토 다운로드

이 튜토리얼을 작성할 당시 Magento의 최신 버전은 2.3.5입니다. Magento 공식 다운로드 페이지에서 다운로드할 수 있습니다.

다운로드가 완료되면 다음 명령을 사용하여 다운로드한 파일을 Apache 웹 루트 디렉터리에 추출합니다.

mkdir /var/www/html/magento
tar -xvjf magento-ce* -C /var/www/html/magento/

다음으로 magento 디렉토리에 적절한 소유권과 권한을 부여합니다.

chown -R www-data:www-data /var/www/html/magento/
chmod -R 755 /var/www/html/magento/

완료되면 다음 단계로 진행할 수 있습니다.

Magento용 Apache 구성

다음으로 Magento 웹 사이트를 제공할 새 Apache 가상 호스트 구성 파일을 만듭니다.

nano /etc/apache2/sites-available/magento.conf

다음 줄을 추가합니다.

<VirtualHost *:80>
     ServerAdmin 
     DocumentRoot /var/www/html/magento/
     ServerName magento.linuxbuz.com
     <Directory /var/www/html/magento/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
     </Directory>
     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

파일을 저장하고 닫은 후 다음 명령을 사용하여 Magento 가상 호스트 및 Apache 재작성 모듈을 활성화합니다.

a2ensite magento.conf
a2enmod rewrite

마지막으로 Apache 서비스를 다시 시작하여 변경 사항을 구현합니다.

systemctl restart apache2

이 시점에서 Apache 웹 서버는 Magento를 제공하도록 구성됩니다.

Lets Encrypt SSL로 Magento 보호

Lets Encrypt 무료 SSL로 웹사이트를 보호하는 것은 항상 좋은 생각입니다. 먼저 서버에 Certbot 클라이언트를 설치하여 웹사이트용 Lets Encrypt SSL을 다운로드하고 구성합니다.

apt-get install certbot python3-certbot-apache -y

Certbot이 설치되면 다음 명령을 실행하여 웹 사이트용 Lets Encrypt SSL을 다운로드하고 설치합니다.

certbot --apache -d magento.linuxbuz.com

유효한 이메일을 제공하고 아래와 같이 서비스 약관에 동의하라는 메시지가 표시됩니다.

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

Obtaining a new certificate
Performing the following challenges:
http-01 challenge for magento.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/magento-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/magento-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/magento-le-ssl.conf

다음으로 HTTP 트래픽을 HTTPS로 리디렉션할지 여부를 선택하라는 메시지가 표시됩니다.

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

2를 입력하고 Enter 키를 눌러 설치를 마칩니다.

Redirecting vhost in /etc/apache2/sites-enabled/magento.conf to ssl vhost in /etc/apache2/sites-available/magento-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://magento.linuxbuz.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=magento.linuxbuz.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/magento.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/magento.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-08-11. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Magento 웹사이트에 액세스

이 시점에서 Magento 웹 사이트는 Lets Encrypt SSL로 보호됩니다.

이제 웹 브라우저를 열고 URL https://magento.linuxbuz.com을 입력하십시오. Magento 웹 기반 설치 마법사로 리디렉션됩니다.

동의 및 Magento 설정 버튼을 클릭합니다. Magento 준비 화면이 표시되어야 합니다.

준비 확인 시작 버튼을 클릭합니다. 준비 확인이 완료되면 다음 화면이 표시됩니다.

다음 버튼을 클릭합니다. 데이터베이스 설정 화면이 표시되어야 합니다.

Magento 데이터베이스 이름, 데이터베이스 사용자 이름, 암호를 제공하고 다음 버튼을 클릭합니다. Magento 웹 구성 마법사가 표시됩니다.

Magento Store 및 관리자 주소를 제공하고 HTTPS를 활성화한 후 다음 버튼을 클릭합니다. Store 사용자 지정 화면이 표시되어야 합니다.

원하는 시간대, 통화, 언어를 설정하고 다음 버튼을 클릭합니다. 관리 사용자 생성 화면이 표시되어야 합니다.

관리자 사용자 이름, 이메일, 비밀번호를 제공하고 다음 버튼을 클릭합니다. 다음 화면이 표시됩니다.

지금 설치 버튼을 클릭하여 설치를 시작합니다. 설치가 성공적으로 완료되면 다음 화면이 표시됩니다.

Magento 관리자 주소를 클릭합니다. Magento 관리 페이지가 표시됩니다.

Magento 관리자 사용자 이름과 암호를 제공하고 로그인 버튼을 클릭합니다. 다음 화면에 Magento 대시보드가 표시되어야 합니다.

URL https://magento.linuxbuz.com을 사용하여 Magento 스토어에 액세스할 수도 있습니다. 다음 화면이 표시됩니다.

결론

축하합니다! Ubuntu 20.04에서 Lets Encrypt SSL을 사용하여 Magento를 성공적으로 설치했습니다. 이제 자신의 온라인 상점을 쉽게 배포할 수 있습니다. 궁금한 점이 있으면 언제든지 문의해 주세요.