GNU/Linux >> Linux の 問題 >  >> Debian

DrupalをApacheでインストールし、Debian11でSSLを暗号化する方法

Drupalは、LAMPスタックに基づく無料のオープンソースコンテンツ管理システムです。 Drupalには、強力なWebサイトやブログを作成できる優れた標準機能があります。プログラミングの知識がなくてもWebサイトを作成するのに役立つ、多くのテーマ、プラグイン、ウィジェットが付属しています。マルチサイトサポート、多言語サポート、コメントシステム、RSSフィード、ユーザー登録などの多くの機能を提供します。

この投稿では、Apacheを使用してDrupalCMSをインストールする方法とDebian11にSSLを暗号化する方法を紹介します。

前提条件
  • Debian11を実行しているサーバー。
  • サーバーIPで指定された有効なドメイン名。
  • ルートパスワードはサーバーで構成されています。

LAMPスタックをインストールする

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データベースを作成する

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のWebサイトにアクセスして、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 [email protected]
     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

この時点で、ApacheWebサーバーはDrupalにサービスを提供するように構成されています。これで、次のステップに進むことができます。

DrupalWebサイトにアクセス

次に、Webブラウザーを開き、URL http://drupal.example.comを使用してDrupalにアクセスします。 。次のページにリダイレクトされます:

英語を選択し、保存して続行をクリックします ボタンをクリックすると、次の画像が表示されます:

インストールプロファイルを選択し、保存して続行をクリックします ボタン。次のページが表示されます:

[データベースの構成]ページで、データベース名、データベースのユーザー名、パスワード、データベースホストなど、必要なすべてのデータベースの詳細を入力し、[保存して続行]をクリックします。 ボタンをクリックすると、次の画像が表示されます:

Drupalサイト構成ページで、サイト名、管理者ユーザー名、およびパスワードを入力し、保存して続行をクリックします。 Drupalのインストールを開始するためのボタン。 Drupalをインストールすると、次の画像にDrupalダッシュボードが表示されます。

DrupalWebサイトでLet'sEncryptSSLサポートを有効にする

Let'sEncryptSSLを使用してWebサイトを保護することは常に良い考えです。まず、SSLをインストールして管理するためにCertbotクライアントをインストールする必要があります。デフォルトでは、CertbotパッケージはDebian 11のデフォルトリポジトリに含まれているため、次のコマンドでインストールできます。

apt-get install python3-certbot-apache -y

Certbotをインストールしたら、次のコマンドを実行して、Let'sEncryptSSLでWebサイトを保護します。

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): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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キーを押して、WebサイトにLet'sEncryptSSLをインストールします。

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
結論

今のところ以上です。これで、Debian11にLet'sEncrypt SSLを使用してDrupalが正常にインストールされました。これで、プログラミングの知識がなくても、独自のブログまたはWebサイトの作成を開始できます。ご不明な点がございましたら、お気軽にお問い合わせください。


Debian
  1. Debian9でApacheを使用してDrupalをインストールおよび構成する方法

  2. ApacheでTikiWikiをインストールし、Debian10でSSLを暗号化する方法

  3. ApacheでAutomadCMSをインストールし、Debian10で暗号化する方法

  1. ElkArteフォーラムをApacheでインストールし、Debian10で暗号化する方法

  2. ApacheでWonderCMSをインストールし、CentOS8でSSLを暗号化する方法

  3. Nginxを使用してOpenCartをインストールし、Debian10で暗号化する方法

  1. Drupal 9をNginxでインストールし、Debian10でSSLを暗号化する方法

  2. ElkArteフォーラムをApacheでインストールし、CentOS8でSSLを暗号化する方法

  3. Apacheを使用してPrestaShopをインストールし、CentOS8でSSLを暗号化する方法