웹사이트 검색

Nginx와 무료로 Shopware를 설치하는 방법 Ubuntu 22.04에서 SSL을 암호화하자


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

  • Ubuntu 22.04(Jammy Jellyfish)
  • Ubuntu 18.04(Bionic Beaver)

이 페이지에서

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

Shopware 커뮤니티 에디션은 웹에서 자신만의 온라인 상점을 시작할 수 있는 무료 오픈 소스 장바구니 플랫폼입니다. Symfony 및 Vue.js로 작성되었으며 최신 기술 스택을 기반으로 합니다. Magento와 같은 다른 전자 상거래 응용 프로그램에 대한 대체 솔루션입니다. 클라이언트 및 주문 관리에 사용되는 아름답고 사용자 친화적인 웹 UI를 제공합니다. 제품 가격을 관리하고, 테마를 변경 또는 업데이트하고, 제품 마케팅을 위한 이메일 템플릿을 디자인하고, 통계 결과를 생성할 수 있습니다.

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

전제 조건

  • 최소 4GB의 RAM이 있는 Ubuntu 22.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/20170718 => /usr/lib/php/20170718

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

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

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

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

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

zend_extension = /usr/lib/php/20170718/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;

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

샵웨어 다운로드

먼저 Nginx 웹 루트 디렉터리 내에 Shopware용 디렉터리를 만듭니다.

mkdir /var/www/html/shopware

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

cd /var/www/html/shopware
wget http://releases.s3.shopware.com.s3.amazonaws.com/install_5.4.5_6847c0845f0f97230aa05c7294fa726a96dda3ff.zip?_ga=2.133696968.774684214.1529926951-1771999509.1528830594 -O shopware.zip

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

unzip shopware.zip

다음으로 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;

    server_name shopware.example.com; # Check this
    root /var/www/html/shopware; # Check this

    index shopware.php index.php;

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

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; # Check this
    }
}

파일을 저장하고 닫은 후 다음 명령을 사용하여 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

Nginx 상태를 확인하려면 다음 명령을 실행합니다.

systemctl status nginx

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

? nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2022-09-12 05:03:41 UTC; 5min ago
       Docs: man:nginx(8)
    Process: 29668 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; -s reload (code=exited, status=0/SUCCESS)
   Main PID: 17628 (nginx)
      Tasks: 3 (limit: 4579)
     Memory: 5.7M
        CPU: 63ms
     CGroup: /system.slice/nginx.service
             ??17628 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             ??29669 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
             ??29670 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

Sep 12 05:03:41 ubuntu2204 systemd[1]: Starting A high performance web server and a reverse proxy server...
Sep 12 05:03:41 ubuntu2204 systemd[1]: Started A high performance web server and a reverse proxy server.
Sep 12 05:09:28 ubuntu2204 systemd[1]: Reloading A high performance web server and a reverse proxy server...
Sep 12 05:09:28 ubuntu2204 systemd[1]: Reloaded A high performance web server and a reverse proxy server.

Shopware 설치 마법사에 액세스

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

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

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

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

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

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

다음 버튼을 클릭합니다. 다음 페이지가 표시됩니다.

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

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

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

로그인 사용자 이름, 비밀번호를 입력하고 로그인 버튼을 클릭합니다. 다음 페이지가 표시됩니다.

이제 상점 설정을 완료하고 Shopware 플랫폼을 사용하여 온라인 판매를 시작하십시오.

Lets Encrypt로 Shopware 보호

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

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

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

certbot --nginx -d shopware.example.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.example.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.example.com

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

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/shopware.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/shopware.example.com/privkey.pem
   Your cert will expire on 2022-09-12. 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.example.com을 사용하여 웹 사이트에 안전하게 액세스할 수 있습니다.

결론

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