웹사이트 검색

Apache로 Prestashop을 설치하고 Debian 11에서 SSL을 암호화하는 방법


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

  • 데비안 11(불스아이)
  • 데비안 9(스트레치)

이 페이지에서

  1. 전제 조건
  2. Apache, MariaDB 및 PHP 설치
  3. PrestaShop용 데이터베이스 만들기
  4. PrestaShop 다운로드
  5. PrestaShop용 Apache 구성
  6. PrestaShop 웹 UI 액세스
  7. Lets Encrypt SSL로 안전한 PrestaShop\n
  8. 결론

PrestaShop은 온라인에서 제품을 판매하는 데 도움이 되는 무료 오픈 소스의 효율적이고 혁신적인 전자 상거래 솔루션입니다. 온라인 상점을 만드는 데 필요한 모든 기능을 제공하는 강력하고 적응력이 뛰어난 전자 상거래 CMS입니다. PrestaShop을 사용하면 재고, 제품 카탈로그, 배송, 송장 발행 등을 관리할 수 있습니다. 5000개 이상의 모듈, 테마를 제공하고 PayPal, Google Checkout 등과 같은 다양한 결제 게이트웨이 시스템을 지원합니다.

이 게시물에서는 Apache 웹 서버와 함께 PrestaShop을 설치하는 방법과 Debian 11에서 Lets Encrypt SSL을 보여줍니다.

전제 조건

  • Debian 11을 실행하는 서버.\n
  • 유효한 도메인 이름은 서버 IP를 가리킵니다.\n
  • 루트 암호는 서버에서 구성됩니다.\n

Apache, MariaDB 및 PHP 설치

먼저 Apache, MariaDB, PHP 및 기타 PHP 확장을 서버에 설치해야 합니다. 다음 명령으로 모두 설치할 수 있습니다.

apt-get install apache2 mariadb-server libapache2-mod-php php php-gd php-mbstring php-mysql php-curl php-xml php-cli php-intl php-zip unzip -y

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

nano /etc/php/7.4/apache2/php.ini

다음 줄을 변경합니다.

memory_limit = 256M
post_max_size = 64M
upload_max_filesize = 32M
date.timezone = UTC

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

systemctl restart apache2

PrestaShop용 데이터베이스 생성

먼저 MariaDB 설치를 보호하고 MariaDB 루트 암호를 설정해야 합니다. mysql_secure_installation 스크립트를 실행하여 이를 수행할 수 있습니다.

mysql_secure_installation

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

Enter current password for root (enter for none): 
Switch to unix_socket authentication [Y/n] Y
Change the 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 루트 암호를 제공한 후 다음 명령을 사용하여 PrestaShop에 대한 사용자 및 데이터베이스를 생성합니다.

MariaDB [(none)]> CREATE DATABASE prestadb;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON prestadb.* TO 'prestauser'@'localhost' IDENTIFIED BY 'yourpass';

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

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

프레스타샵 다운로드

그런 다음 PrestaShop 웹사이트로 이동하여 다음 명령을 사용하여 최신 버전의 PrestaShop을 다운로드합니다.

wget https://download.prestashop.com/download/releases/prestashop_1.7.7.7.zip

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

unzip prestashop_1.7.7.7.zip

다음으로, 다음 명령을 사용하여 Apache 웹 루트 디렉터리 내에서 PrestaShop의 압축을 다시 풉니다.

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

다음으로 PrestaShop 디렉토리에 대한 적절한 소유권 및 권한을 설정합니다.

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

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

PrestaShop용 Apache 구성

다음으로 PrestaShop용 Apache 가상 호스트 구성 파일을 생성해야 합니다. 다음 명령으로 만들 수 있습니다.

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

다음 줄을 추가합니다.

<VirtualHost *:80>
      ServerAdmin 
      ServerName presta.example.com
      DocumentRoot /var/www/html/prestashop


     <Directory /var/www/html/prestashop>
          Options FollowSymlinks
          AllowOverride All
          Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/your-domain.com_error.log
     CustomLog ${APACHE_LOG_DIR}/your-domain.com_access.log combined

</VirtualHost>

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

a2enmod rewrite
a2ensite prestashop

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

systemctl restart apache2

다음 명령을 사용하여 Apache 서비스를 확인할 수도 있습니다.

systemctl status apache2

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

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2021-08-27 06:15:23 UTC; 5min ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 17540 ExecReload=/usr/sbin/apachectl graceful (code=exited, status=0/SUCCESS)
   Main PID: 14330 (apache2)
      Tasks: 6 (limit: 2341)
     Memory: 16.5M
        CPU: 332ms
     CGroup: /system.slice/apache2.service
             ??14330 /usr/sbin/apache2 -k start
             ??17544 /usr/sbin/apache2 -k start
             ??17545 /usr/sbin/apache2 -k start
             ??17546 /usr/sbin/apache2 -k start
             ??17547 /usr/sbin/apache2 -k start
             ??17548 /usr/sbin/apache2 -k start

Aug 27 06:15:23 debian11 systemd[1]: Starting The Apache HTTP Server...

PrestaShop 웹 UI에 액세스

이 시점에서 PrestaShop이 설치되고 구성됩니다. 이제 URL http://presta.example.com을 사용하여 액세스할 수 있습니다. 다음 페이지가 표시됩니다.

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

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

스토어 이름, 관리자 계정 세부 정보를 제공하고 다음 버튼을 클릭합니다. 다음 페이지가 표시됩니다.

데이터베이스 설정을 제공하고 다음 버튼을 클릭하여 설치를 시작하십시오. 설치가 완료되면 다음 페이지가 표시됩니다.

스토어 관리 버튼을 클릭합니다. 다음 페이지가 표시됩니다.

그런 다음 터미널을 열고 설치 폴더를 제거하십시오.

rm -rf /var/www/html/prestashop/install

이제 이전 화면에 표시된 URL을 사용하여 PrestaShop 관리 인터페이스에 액세스하십시오. PrestaShop 로그인 화면이 표시됩니다.

관리자 사용자 이름, 암호를 제공하고 로그인 버튼을 클릭합니다. 다음 페이지에 PrestaShop 대시보드가 표시됩니다.

Lets Encrypt SSL로 안전한 PrestaShop

먼저 도메인용 SSL 인증서를 다운로드하고 설치하려면 Certbot Lets Encrypt 클라이언트를 설치해야 합니다.

다음 명령으로 설치할 수 있습니다.

apt-get install python3-certbot-apache -y

일단 설치되면 다음 명령을 실행하여 도메인 prestashop.example.com에 대한 Lets Encrypt 인증서를 설치할 수 있습니다.

certbot --apache -d presta.example.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 prestashop.example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/prestashop-le-ssl.conf
Deploying Certificate to VirtualHost /etc/apache2/sites-available/prestashop-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/prestashop-le-ssl.conf

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 키를 눌러 도메인용 무료 SSL 인증서를 다운로드하고 설치합니다. 일단 설치가 성공적으로 완료되었습니다. 다음 출력이 표시되어야 합니다.

Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/prestashop.conf to ssl vhost in /etc/apache2/sites-available/
prestashop-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://prestashop.example.com

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

결론

위 가이드에서는 Apache로 PrestaShop을 설치하는 방법과 Debian 11에서 Lets Encrypt SSL 인증서를 설치하는 방법을 설명했습니다. 이제 PrestaShop으로 온라인 상점을 쉽게 호스팅할 수 있습니다. 궁금한 점이 있으면 언제든지 문의해 주세요.