웹사이트 검색

NGINX로 Shopware 6을 설치하고 CentOS 8에서 암호화하는 방법


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

  • 센트OS 8
  • 센트OS 7.6

이 페이지에서

  1. 전제 조건
  2. LEMP 서버 설치
  3. PHP-FPM 구성
  4. Shopware용 데이터베이스 생성
  5. 샵웨어 다운로드
  6. Shopware용 Nginx 구성
  7. SELinux 및 방화벽 구성\n
  8. Shopware 웹 인터페이스 액세스
  9. Lets Encrypt SSL로 Shopware 보호\n
  10. 결론

Shopware는 온라인 비즈니스를 지원하는 전자 상거래 웹 사이트를 시작하는 데 도움이 되는 무료 오픈 소스 플랫폼입니다. 완전히 반응하는 온라인 상점을 구축하고 사용자 지정하는 데 도움이 되는 많은 유용한 도구를 제공합니다. 마젠토와 매우 유사합니다. Magento에 비해 Shopware는 매우 강력하고 사용하기 쉽고 유연한 애플리케이션입니다. 최신 사용자 인터페이스를 통해 모든 장치에서 콘텐츠와 제품을 쉽게 만들고 관리할 수 있습니다.

이 튜토리얼에서는 Nginx로 Shopware를 설치하고 CentOS 8에서 Lets Encrypt SSL을 사용하는 방법을 보여줍니다.

전제 조건

  • CentOS 8을 실행하는 서버.\n
  • 서버 IP를 가리키는 유효한 도메인 이름입니다.\n
  • 서버에 루트 암호가 구성되어 있습니다.\n

LEMP 서버 설치

Shopware는 웹 서버에서 실행되며 Symfony 및 Zend 구성 요소와 함께 PHP를 기반으로 구축되며 MySQL 또는 MariaDB를 데이터베이스 백엔드로 사용합니다. 따라서 서버에 Nginx, MariaDB, PHP 및 기타 확장을 설치해야 합니다. 다음 명령으로 모두 설치할 수 있습니다.

dnf install nginx mariadb-server php php-cli php-intl php-fpm php-common php-mysqli php-curl php-json php-zip php-gd php-xml php-mbstring php-opcache unzip -y

모든 패키지가 설치되면 Nginx, MariaDB 및 PHP-FPM 서비스를 시작하고 다음 명령을 사용하여 시스템 재부팅 시 시작할 수 있도록 합니다.

systemctl start mariadb
systemctl enable mariadb
systemctl start nginx
systemctl start php-fpm
systemctl enable nginx
systemctl enable php-fpm

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

PHP-FPM 구성

기본적으로 PHP-FPM은 Apache 사용자 및 그룹으로 실행되도록 구성됩니다. 따라서 Nginx 사용자 및 그룹으로 실행되도록 구성해야 합니다. /etc/php-fpm.d/www.conf 파일을 편집하면 됩니다.

nano /etc/php-fpm.d/www.conf

다음 줄을 변경합니다.

user = nginx 
group = nginx 

파일을 저장하고 닫은 다음 세션 디렉터리를 만들고 다음 명령을 사용하여 적절한 소유권을 설정합니다.

mkdir -p /var/lib/php/session 
chown -R nginx:nginx /var/lib/php/session

다음으로 php.ini 파일을 편집하고 몇 가지 권장 설정을 조정합니다.

nano /etc/php.ini

다음 줄을 변경합니다.

memory_limit = 512M
upload_max_filesize = 20M
date.timezone = Asia/Kolkata

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

systemctl restart php-fpm

Shopware용 데이터베이스 생성

다음으로 Shopware용 데이터베이스와 사용자를 생성해야 합니다. 먼저 다음 명령을 사용하여 MariaDB에 연결합니다.

mysql

연결되면 다음 명령을 사용하여 데이터베이스와 사용자를 만듭니다.

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

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

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

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

샵웨어 다운로드

다음으로 공식 웹사이트용 Shopware 최신 버전을 다운로드해야 합니다. 먼저 Nginx 루트 디렉터리 내에 Shopware용 디렉터리를 만듭니다.

mkdir /var/www/html/shopware

그런 다음 다음 명령을 사용하여 Shopware를 다운로드합니다.

wget https://www.shopware.com/en/Download/redirect/version/sw6/file/install_v6.3.5.0_ba08dbfc07784b5cefe7837f2abbda69dbf5b8b7.zip -O shopware.zip

다운로드가 완료되면 다운로드한 파일을 shopware 디렉토리에 추출합니다.

unzip shopware.zip -d /var/www/html/shopware

그런 다음 다음 명령을 사용하여 적절한 권한과 소유권을 설정합니다.

chown -R nginx:nginx /var/www/html/shopware
chmod -R 775 /var/www/html/shopware

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

Shopware용 Nginx 구성

다음으로 다음 명령을 사용하여 Shopware용 Nginx 가상 호스트 구성 파일을 만듭니다.

nano /etc/nginx/conf.d/shopware.conf

다음 줄을 추가합니다.

server {
    listen 80;

    # Handle / to index.php
    index index.php;

    # Our server name
    server_name shopware.example.com;

    # Where the code is located
    root /var/www/html/shopware/public;

    # Needed for Shopware install / update
    location /recovery/install {
        index index.php;
        try_files $uri /recovery/install/index.php$is_args$args;
    }

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

    # Forward any not found file to index.php. Also allows to have beautiful urls like /homemade-products/
    location / {
        try_files $uri /index.php$is_args$args;
    }

    # Let php-fpm handle .php files
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi.conf;
        fastcgi_param HTTP_PROXY "";
        fastcgi_buffers 8 16k;
        fastcgi_buffer_size 32k;
        fastcgi_read_timeout 300s;
        client_body_buffer_size 128k;
        fastcgi_pass unix:/run/php-fpm/www.sock;
        http2_push_preload on;
    }
}

파일을 저장하고 닫은 후 다음 명령을 사용하여 구문 오류가 있는지 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 restart nginx

아래 명령을 사용하여 Nginx 상태를 확인할 수도 있습니다.

systemctl status nginx

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

? nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
  Drop-In: /usr/lib/systemd/system/nginx.service.d
           ??php-fpm.conf
   Active: active (running) since Tue 2021-02-02 00:40:04 EST; 19s ago
  Process: 76059 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 76057 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 76054 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 76060 (nginx)
    Tasks: 3 (limit: 12523)
   Memory: 5.5M
   CGroup: /system.slice/nginx.service
           ??76060 nginx: master process /usr/sbin/nginx
           ??76061 nginx: worker process
           ??76062 nginx: worker process

Feb 02 00:40:04 centos8 systemd[1]: Stopped The nginx HTTP and reverse proxy server.
Feb 02 00:40:04 centos8 systemd[1]: Starting The nginx HTTP and reverse proxy server...
Feb 02 00:40:04 centos8 nginx[76057]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Feb 02 00:40:04 centos8 nginx[76057]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Feb 02 00:40:04 centos8 systemd[1]: Started The nginx HTTP and reverse proxy server.

SELinux 및 방화벽 구성

기본적으로 SELinux는 CentOS 8에서 활성화되어 있습니다. 따라서 Shopware용 SELinux 컨텍스트를 구성해야 합니다. 다음 명령으로 구성할 수 있습니다.

setsebool httpd_can_network_connect on -P
chcon -R -u system_u -t httpd_sys_rw_content_t -r object_r /var/www/html/shopware

그런 다음 다음 명령을 사용하여 방화벽을 통해 포트 80 및 443을 허용합니다.

firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload

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

Shopware 웹 인터페이스에 액세스

이제 웹 브라우저를 열고 URL http://shopware.example.com을 입력하십시오.

언어를 선택하고 다음 버튼을 클릭합니다. 모든 요구 사항이 충족되었는지 확인하고 다음 버튼을 클릭합니다. 다음 페이지가 표시됩니다.

GTC에 동의하고 다음 버튼을 클릭합니다. 다음 페이지가 표시됩니다.

데이터베이스, 사용자 이름, 암호를 제공하고 설치 시작 버튼을 클릭합니다. 설치가 완료되면 다음 페이지가 표시됩니다.

다음 페이지를 클릭합니다. 상점 이름, 이메일 주소, 통화, 국가, 관리자 사용자 이름, 비밀번호를 입력하고 다음 버튼을 클릭하라는 메시지가 표시됩니다. Shopware 대시보드로 리디렉션됩니다.

모든 정보를 입력하고 다음 버튼을 클릭합니다. 다음 페이지가 표시됩니다.

원하는 언어 플러그인을 설치하고 다음 버튼을 클릭합니다. 다음 페이지가 표시됩니다.

데모 데이터를 설치하거나 건너뛰고 다음 버튼을 클릭합니다. 다음 페이지가 표시됩니다.

나중에 구성을 클릭합니다. 다음 페이지가 표시됩니다.

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

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

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

마침 버튼을 클릭합니다. Shopware 시작 페이지가 표시됩니다.

Lets Encrypt SSL로 Shopware 보호

다음으로 Lets Chat 도메인용 Lets Encrypt SSL을 다운로드하고 설치하려면 시스템에 Certbot 유틸리티를 설치해야 합니다.

다음 명령을 사용하여 Certbot 클라이언트를 설치할 수 있습니다.

wget https://dl.eff.org/certbot-auto
mv certbot-auto /usr/local/bin/certbot-auto
chown root /usr/local/bin/certbot-auto
chmod 0755 /usr/local/bin/certbot-auto

그런 다음 다음 명령을 사용하여 lets 도메인에 대한 SSL 인증서를 가져와 설치합니다.

certbot-auto --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/conf.d/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/conf.d/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 2021-04-2. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot-auto
   again with the "certonly" option. To non-interactively renew *all*
   of your certificates, run "certbot-auto 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

이제 URL https://shopware.example.com을 사용하여 Shopware에 안전하게 액세스할 수 있습니다.

결론

축하합니다! Nginx로 Shopware를 성공적으로 설치하고 구성했으며 CentOS 8에서 Lets Encrypt SSL을 사용했습니다. 이제 Shopware로 자신의 온라인 상점을 쉽게 호스팅할 수 있습니다. 궁금한 점이 있으면 언제든지 문의해 주세요.