웹사이트 검색

Nginx로 Shopware 6을 설치하고 Ubuntu 20.04에서 SSL을 암호화하는 방법


이 튜토리얼은 다음 OS 버전에 대해 존재합니다.

  • 우분투 18.04(바이오닉 비버)

이 페이지에서

  1. 전제 조건
  2. Nginx 및 MariaDB 설치
  3. PHP 및 기타 구성 요소 설치
  4. MariaDB 데이터베이스 구성
  5. 작성기 설치
  6. 샵웨어 다운로드
  7. Shopware용 Nginx 구성
  8. 샵웨어 설치 마법사 액세스
  9. Lets Encrypt로 Shopware 보호\n
  10. 결론

Shopware CE는 Symfony 및 Vue.js로 작성된 무료 오픈 소스 전자상거래 플랫폼입니다. 매우 현대적인 기술 스택을 기반으로 하며 Magento와 같은 다른 전자 상거래 애플리케이션에 대한 매우 좋은 대안입니다. 매우 강력하고 유연한 애플리케이션이며 성장 잠재력을 빠르고 쉽게 활용하고 완벽한 고객 경험에 집중할 수 있는 자유를 제공합니다. 클라이언트 및 주문 관리를 위한 간단하고 사용하기 쉬운 관리 인터페이스를 제공합니다. 제품 가격을 관리하고, 테마를 변경 또는 업데이트하고, 제품 마케팅을 위한 이메일 템플릿을 디자인하고, 통계 결과를 생성할 수 있습니다.

이 튜토리얼에서는 Ubuntu 20.04에서 Nginx 및 Lets Encrypt와 함께 Shopware CE를 설치하는 방법을 보여줍니다.

전제 조건

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

Nginx 및 MariaDB 설치

먼저 다음 명령을 사용하여 Nginx 웹 서버와 MariaDB 데이터베이스 서버를 설치합니다.

apt-get install nginx mariadb-server -y

두 패키지가 모두 설치되면 Nginx 및 MariaDB 서비스를 시작하고 시스템 부팅 시 시작할 수 있도록 활성화합니다.

systemctl start nginx
systemctl start mariadb
systemctl enable nginx
systemctl enable mariadb

PHP 및 기타 구성 요소 설치

Shopware 6은 7.2에서 7.3 사이의 PHP 버전을 지원합니다. 따라서 시스템에 다른 라이브러리와 함께 PHP를 설치해야 합니다.

먼저 다음 명령을 사용하여 시스템에 PHP 리포지토리를 추가합니다.

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

리포지토리가 추가되면 다음 명령을 사용하여 다른 라이브러리와 함께 PHP를 설치합니다.

apt-get install php7.2 php7.2-cli php7.2-fpm php7.2-common php7.2-mysql php7.2-curl php7.2-json php7.2-zip php7.2-gd php7.2-xml php7.2-mbstring php7.2-intl php7.2-opcache git unzip socat curl bash-completion -y

모든 패키지가 설치되면 php.ini 파일을 편집하고 원하는 설정을 조정합니다.

nano /etc/php/7.2/fpm/php.ini

다음 줄을 변경합니다.

memory_limit = 512M
upload_max_filesize = 20M
max_execution_time = 300

완료되면 파일을 저장하고 닫습니다.

다음으로 시스템에 IonCube 로더를 설치해야 합니다.

먼저 다음 명령으로 다운로드합니다.

wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz

다운로드가 완료되면 다음 명령을 사용하여 다운로드한 파일의 압축을 풉니다.

tar xfz ioncube_loaders_lin_x86-64.tar.gz

다음으로 PHP 확장 디렉토리의 경로를 찾습니다.

php -i | grep extension_dir

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

extension_dir => /usr/lib/php/20190902 => /usr/lib/php/20190902

다음으로 IonCube 로더를 PHP 확장 디렉터리에 복사합니다.

cp ioncube/ioncube_loader_lin_7.2.so /usr/lib/php/20180731/

다음으로 php.ini 파일을 편집하고 IonCube 로더를 정의합니다.

nano /etc/php/7.2/fpm/php.ini

[PHP] 섹션 안에 다음 줄을 추가합니다.

zend_extension = /usr/lib/php/20180731/ioncube_loader_lin_7.2.so

파일을 저장하고 닫은 다음 PHP-FPM 서비스를 다시 시작하여 변경 사항을 적용하십시오.

systemctl restart php7.2-fpm

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 셸에 로그인합니다.

mysql -u root -p

MariaDB 루트 암호를 제공한 다음 Shopware용 데이터베이스 및 사용자를 생성합니다.

MariaDB [(none)]> CREATE DATABASE shopwaredb;
MariaDB [(none)]> GRANT ALL ON shopwaredb.* TO 'shopware'@'localhost' IDENTIFIED BY 'password';

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

MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit;

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

작곡가 설치

Composer는 PHP의 종속성 관리자입니다. Shopware를 설치하는 데 필요한 모든 PHP 종속성을 설치하는 데 사용됩니다.

아래와 같이 curl 명령을 사용하여 설치할 수 있습니다.

curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer

설치가 완료되면 다음 명령을 사용하여 Composer 버전을 확인합니다.

composer --version

다음과 같은 결과가 표시되어야 합니다.

Composer version 1.10.7 2020-06-03 10:03:56

샵웨어 다운로드

먼저 Nginx 웹 루트 디렉토리 내에 Shopware용 디렉토리를 생성합니다.

mkdir /var/www/html/shopware

그런 다음 디렉토리를 shopware로 변경하고 다음 명령을 사용하여 최신 버전의 Shopware를 다운로드합니다.

cd /var/www/html/shopware
wget https://www.shopware.com/en/Download/redirect/version/sw6/file/install_6.2.2_1592398977.zip

다운로드가 완료되면 다음 명령을 사용하여 다운로드한 파일의 압축을 풉니다.

unzip install_6.2.2_1592398977.zip

다음으로 다음 명령을 사용하여 모든 PHP 종속성을 설치합니다.

composer install

다음으로 shopware 디렉토리의 소유권을 변경하고 다음 명령을 사용하여 적절한 권한을 부여하십시오.

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

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

Shopware용 Nginx 구성

먼저 Shopware용 새 Nginx 가상 호스트 구성 파일을 만듭니다.

nano /etc/nginx/sites-available/shopware.conf

다음 줄을 추가합니다.

server {
    listen 80;

    index index.php index.html;
    server_name shopware.linuxbuz.com;
    root /var/www/html/shopware/public;

    location /recovery/install {
        index index.php;
        try_files $uri /recovery/install/index.php$is_args$args;
    }

    location /recovery/update/ {
        location /recovery/update/assets {
        }
        if (!-e $request_filename){
            rewrite . /recovery/update/index.php last;
        }
    }

    location / {
        try_files $uri /index.php$is_args$args;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi.conf;
        fastcgi_param HTTP_PROXY "";
        fastcgi_buffers 8 16k;
        fastcgi_buffer_size 32k;
        client_max_body_size 24M;
        client_body_buffer_size 128k;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        http2_push_preload on;
    }
}

파일을 저장하고 닫은 다음 다음 명령을 사용하여 Shopware 가상 호스트 파일을 활성화합니다.

ln -s /etc/nginx/sites-available/shopware.conf /etc/nginx/sites-enabled/

다음으로 다음 명령을 사용하여 Nginx에서 구문 오류가 있는지 확인합니다.

nginx -t

다음과 같은 결과가 표시되어야 합니다.

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

그런 다음 Nginx 서비스를 다시 시작하여 변경 사항을 적용합니다.

systemctl reload nginx

Shopware 설치 마법사에 액세스

이 시점에서 Shopware가 시스템에 설치됩니다. 이제 웹 브라우저를 열고 URL http://shopware.linuxbuz.com을 입력하십시오. Shopware 웹 설치 마법사가 표시됩니다.

언어를 선택하고 다음 버튼을 클릭합니다. 다음 화면이 표시됩니다.

필요한 모든 종속성이 설치되었는지 확인한 후 다음 버튼을 클릭합니다. 다음 화면이 표시됩니다.

이용 약관에 동의하고 다음 버튼을 클릭합니다. 다음 화면이 표시됩니다.

데이터베이스 세부 정보를 제공하고 설치 시작 버튼을 클릭합니다. 설치가 성공적으로 완료되면 다음 화면이 표시됩니다.

이제 다음 버튼을 클릭합니다. Shopware 구성 화면이 표시됩니다.

상점 이름, 이메일, 국가, 관리자 이메일, 관리자 사용자 이름, 비밀번호를 제공하고 다음 버튼을 클릭합니다. Shopware 대시보드 화면으로 리디렉션됩니다.

다음 버튼을 클릭합니다. 다음 화면이 표시됩니다.

원하는 데이터를 설치하고 다음 버튼을 클릭합니다. 다음 화면이 표시됩니다.

원하는 이메일 에이전트를 선택하고 다음 버튼을 클릭합니다. 다음 화면이 표시됩니다.

원하는 옵션을 선택하고 다음 버튼을 클릭합니다. 다음 화면이 표시됩니다.

PayPal을 구성하거나 건너뛰기 버튼을 클릭합니다. 다음 화면이 표시됩니다.

PayPal 자격 증명을 구성하거나 건너뛰기 버튼을 클릭합니다. 다음 화면이 표시됩니다.

지역을 선택하고 다음 버튼을 클릭합니다. 다음 화면이 표시됩니다.

건너뛰기 버튼을 클릭합니다. Shopware가 구성되면 다음 화면이 표시됩니다.

마침 버튼을 클릭합니다. 다음 화면에 Shopware 대시보드가 표시되어야 합니다.

Lets Encrypt로 Shopware 보호

시작하기 전에 Lets Encrypt SSL을 설치하고 관리하려면 시스템에 Certbot 클라이언트를 설치해야 합니다. 다음 명령을 사용하여 설치할 수 있습니다.

apt-get install certbot python3-certbot-nginx -y

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

certbot --nginx -d shopware.linuxbuz.com

이메일 주소를 제공하고 아래와 같이 서비스 약관에 동의하십시오.

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
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 shopware.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/shopware.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 all traffic on port 80 to ssl in /etc/nginx/sites-enabled/shopware.conf

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

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

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/shopware.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/shopware.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-09-22. 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"
 - 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

이 시점에서 Shopware 웹사이트는 Lets Encrypt SSL로 보호됩니다. 이제 URL https://shopware.linuxbuz.com을 사용하여 웹사이트에 안전하게 액세스할 수 있습니다.

결론

축하합니다! Nginx와 함께 Shopware를 성공적으로 설치했으며 Ubuntu 20.04에서 Lets Encrypt SSL을 사용했습니다. 이제 Shopware를 사용하여 온라인 비즈니스를 시작할 수 있습니다. 궁금한 점이 있으면 언제든지 문의해 주세요.