웹사이트 검색

Apache와 함께 Drupal을 설치하고 Debian 11에서 SSL을 암호화하는 방법


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

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

이 페이지에서

  1. 전제 조건
  2. LAMP 스택 설치
  3. Drupal 데이터베이스 만들기
  4. 드루팔 다운로드
  5. Drupal용 Apache 가상 호스트 만들기\n
  6. Drupal 웹사이트 액세스
  7. Drupal 웹사이트에서 Lets Encrypt SSL 지원 활성화\n
  8. 결론

Drupal은 LAMP 스택을 기반으로 하는 무료 오픈 소스 콘텐츠 관리 시스템입니다. Drupal에는 강력한 웹사이트와 블로그를 만들 수 있는 훌륭한 표준 기능이 있습니다. 프로그래밍 지식 없이도 웹 사이트를 만드는 데 도움이 되는 많은 테마, 플러그인 및 위젯이 함께 제공됩니다. 멀티 사이트 지원, 다국어 지원, 댓글 시스템, RSS 피드, 사용자 등록 등 많은 기능을 제공합니다.

이 게시물에서는 Apache와 함께 Drupal CMS를 설치하는 방법과 Debian 11에서 Lets Encrypt SSL을 사용하는 방법을 보여줍니다.

전제 조건

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

램프 스택 설치

Drupal은 LAMP 스택을 기반으로 합니다. 따라서 서버에 LAMP 스택을 설치해야 합니다. 설치되어 있지 않은 경우 다음 명령을 실행하여 설치할 수 있습니다.

apt-get install apache2 mariadb-server mariadb-client php libapache2-mod-php php-cli php-mysql php-zip php-gd php-fpm php-json php-common php-intl php-mbstring php-curl php-xml php-pear php-tidy php-soap php-bcmath php-xmlrpc -y

LAMP 스택이 설치되면 php.ini 파일을 편집하고 몇 가지 기본 설정을 변경합니다.

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

다음 줄을 변경합니다.

memory_limit = 256M
upload_max_filesize = 32M
max_execution_time = 300
date.timezone = Asia/Kolkata

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

드루팔 데이터베이스 생성

Drupal은 MariaDB를 데이터베이스 백엔드로 사용합니다. 따라서 Drupal용 데이터베이스와 사용자를 생성해야 합니다.

먼저 다음 명령을 사용하여 MariaDB에 로그인합니다.

mysql

로그인한 후 다음 명령을 사용하여 데이터베이스와 사용자를 생성합니다.

MariaDB [(none)]> CREATE DATABASE drupaldb;
MariaDB [(none)]> CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY "securepassword";

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

MariaDB [(none)]> GRANT ALL ON drupaldb.* TO 'drupaluser'@'localhost' IDENTIFIED BY "securepassword";

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

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

드루팔 다운로드

먼저 Drupal 웹 사이트로 이동하여 Drupal의 최신 버전을 선택하고 다음 명령을 사용하여 다운로드합니다.

wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz

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

tar -xvf drupal.tar.gz

다음으로 추출된 디렉터리를 Apache 기본 루트 디렉터리로 이동합니다.

mv drupal-* /var/www/html/drupal

다음으로 다음 명령을 사용하여 Drupal 디렉터리의 소유권과 권한을 변경합니다.

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

Drupal용 Apache 가상 호스트 만들기

다음으로 Drupal을 호스팅하기 위해 Apache 가상 호스트 구성 파일을 생성해야 합니다. 다음 명령을 사용하여 만들 수 있습니다.

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

다음 줄을 추가합니다.

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

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

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

     <Directory /var/www/html/>
            RewriteEngine on
            RewriteBase /
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    </Directory>
</VirtualHost>

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

a2ensite drupal.conf
a2enmod rewrite

다음으로 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 Sat 2021-09-18 14:59:40 UTC; 5s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 19698 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 19703 (apache2)
      Tasks: 6 (limit: 2341)
     Memory: 15.3M
        CPU: 78ms
     CGroup: /system.slice/apache2.service
             ??19703 /usr/sbin/apache2 -k start
             ??19704 /usr/sbin/apache2 -k start
             ??19705 /usr/sbin/apache2 -k start
             ??19706 /usr/sbin/apache2 -k start
             ??19707 /usr/sbin/apache2 -k start
             ??19708 /usr/sbin/apache2 -k start

이 시점에서 Apache 웹 서버는 Drupal을 제공하도록 구성됩니다. 이제 다음 단계를 진행할 수 있습니다.

Drupal 웹 사이트에 액세스

이제 웹 브라우저를 열고 URL http://drupal.example.com을 사용하여 Drupal에 액세스하십시오. 다음 페이지로 리디렉션됩니다.

영어를 선택하고 저장하고 계속하기 버튼을 클릭하면 다음 이미지가 표시됩니다.

설치 프로필을 선택하고 저장 및 계속 버튼을 클릭합니다. 다음 페이지가 표시됩니다.

데이터베이스 구성 페이지에서 데이터베이스 이름, 데이터베이스 사용자 이름, 암호, 데이터베이스 호스트와 같은 필요한 모든 데이터베이스 세부 정보를 제공한 다음 저장 및 계속 버튼을 클릭하면 다음 이미지가 표시됩니다.

Drupal 사이트 구성 페이지에서 사이트 이름, 관리자 사용자 이름 및 암호를 제공한 다음 저장 및 계속 버튼을 클릭하여 Drupal 설치를 시작합니다. Drupal이 설치되면 다음 이미지에서 Drupal 대시보드를 볼 수 있습니다.

Drupal 웹 사이트에서 Lets Encrypt SSL 지원 활성화

Lets Encrypt SSL로 웹 사이트를 보호하는 것은 항상 좋은 생각입니다. 먼저 SSL을 설치하고 관리하려면 Certbot 클라이언트를 설치해야 합니다. 기본적으로 Certbot 패키지는 Debian 11 기본 리포지토리에 포함되어 있으므로 다음 명령으로 설치할 수 있습니다.

apt-get install python3-certbot-apache -y

Certbot이 설치되면 다음 명령을 실행하여 Lets Encrypt SSL로 웹 사이트를 보호하십시오.

certbot --apache -d drupal.example.com

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

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
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
Plugins selected: Authenticator apache, Installer apache
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for drupal.example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/drupal-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/drupal-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/drupal-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 키를 눌러 웹사이트에 Lets Encrypt SSL을 설치합니다.

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

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

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

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/drupal.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/drupal.example.com/privkey.pem
   Your cert will expire on 2021-04-20. 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

결론

지금은 그게 다야. Debian 11에 Lets Encrypt SSL을 사용하여 Drupal을 성공적으로 설치했습니다. 이제 프로그래밍 지식 없이도 자신만의 블로그나 웹 사이트를 만들 수 있습니다. 궁금한 점이 있으면 언제든지 문의해 주세요.