GNU/Linux >> Linux の 問題 >  >> Ubuntu

Apache2とUbuntu20.04でのLetsEncryptを使用したMagentoEコマースプラットフォームのインストール

Magentoは、完全に機能するeコマースストアを数分で作成できる無料のオープンソースeコマースWebアプリケーションです。これはPHPで記述されており、強力な機能と柔軟性およびユーザーフレンドリーなインターフェイスを兼ね備えています。シンプルで強力な管理パネルにより、セルフホストのオンラインストアで最も人気のあるソリューションの1つです。サイト管理、SEO、カタログ管理、製品とカタログの閲覧、注文管理、チェックアウト、プロモーションと変換ツールなどの豊富な機能セットが付属しています。

このチュートリアルでは、Apacheを使用してMagento Eコマースプラットフォームをインストールし、Ubuntu20.04にSSLを暗号化する方法を示します。

前提条件
  • 4GBのRAMを搭載したUbuntu20.04を実行しているサーバー。
  • サーバーで指定された有効なドメイン名。
  • ルートパスワードはサーバーで構成されています。

LAMPサーバーをインストールする

Magentoは、PHPで記述されたWebサーバー上で実行され、MariaDBをデータベースとして使用します。そのため、サーバーにLAMPスタックをインストールする必要があります。

まず、次のコマンドを使用してApacheWebサーバーとMariaDBサーバーをインストールします。

apt-get install apache2 mariadb-server mariadb-client -y

Magentoの最新バージョンは、PHP7.1.3+および7.2.xとのみ互換性があります。そのため、サポートされているPHPバージョンと必要な拡張機能をサーバーにインストールする必要があります。

デフォルトでは、Ubuntu20.04にはPHPバージョン7.4が付属しています。したがって、他のPHPバージョンをインストールするには、システムにOndrejPPAを追加する必要があります。

次のコマンドを使用して、OndrejPHPPPAを追加できます。

apt-get install software-properties-common -y
add-apt-repository ppa:ondrej/php

次に、リポジトリを更新し、次のコマンドを使用して他の必要な拡張機能を使用してPHPをインストールします。

apt-get install php7.2 libapache2-mod-php7.2 php7.2-bcmath php7.2-common php7.2-mbstring php7.2-xmlrpc php7.2-soap php7.2-gd php7.2-xml php7.2-intl php7.2-mysql php7.2-cli php7.2-ldap php7.2-zip php7.2-curl wget curl unzip -y

終了したら、次のステップに進むことができます。

MariaDBデータベースを構成する

デフォルトでは、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が保護されたら、MariaDBシェルにログインします。

mysql -u root -p

MariaDBのrootパスワードを入力してから、Magentoのデータベースとユーザーを作成します。

MariaDB [(none)]> CREATE DATABASE magentodb;
MariaDB [(none)]> CREATE USER 'magento'@'localhost' IDENTIFIED BY 'password';

次に、次のコマンドを使用して、Magentoデータベースにすべての権限を付与します。

MariaDB [(none)]> GRANT ALL ON magentodb.* TO 'magento'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

次に、特権をフラッシュし、次のコマンドを使用してMariaDBシェルを終了します。

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

完了したら、次のステップに進むことができます。

Magentoをダウンロード

このチュートリアルを書いている時点では、Magentoの最新バージョンは2.3.5です。 Magentoの公式ダウンロードページからダウンロードできます。

ダウンロードしたら、次のコマンドを使用して、ダウンロードしたファイルをApacheWebルートディレクトリに抽出します。

mkdir /var/www/html/magento
tar -xvjf magento-ce* -C /var/www/html/magento/

次に、magentoディレクトリに適切な所有権と権限を付与します:

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

完了したら、次のステップに進むことができます。

Magento用にApacheを構成する

次に、MagentoWebサイトにサービスを提供するための新しいApache仮想ホスト構成ファイルを作成します。

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

次の行を追加します:

<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /var/www/html/magento/
     ServerName magento.linuxbuz.com
     <Directory /var/www/html/magento/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
     </Directory>
     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
からの許可を拒否します

ファイルを保存して閉じてから、次のコマンドでMagento仮想ホストとApacheリライトモジュールを有効にします。

a2ensite magento.conf
a2enmod rewrite

最後に、Apacheサービスを再起動して、変更を実装します。

systemctl restart apache2

この時点で、ApacheWebサーバーはMagentoを提供するように構成されています。

SSLを暗号化してLet'sで安全なMagento

Let'sEncryptの無料SSLを使用してWebサイトを保護することをお勧めします。まず、サーバーにCertbotクライアントをインストールして、Webサイト用にLet'sEncryptSSLをダウンロードして構成します。

apt-get install certbot python3-certbot-apache -y

Certbotがインストールされたら、次のコマンドを実行して、Webサイト用のLet'sEncryptSSLをダウンロードしてインストールします。

certbot --apache -d magento.linuxbuz.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): [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

Obtaining a new certificate
Performing the following challenges:
http-01 challenge for magento.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/magento-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/magento-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/magento-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を押します インストールを完了します。

Redirecting vhost in /etc/apache2/sites-enabled/magento.conf to ssl vhost in /etc/apache2/sites-available/magento-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://magento.linuxbuz.com

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

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/magento.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/magento.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-08-11. 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"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - 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
MagentoのWebサイトにアクセス

この時点で、MagentoのWebサイトはLet'sEncryptSSLで保護されています。

次に、Webブラウザーを開き、URLhttps://magento.linuxbuz.comを入力します。 MagentoのWebベースのインストールウィザードにリダイレクトされます:

同意してをクリックします セットアップ Magento ボタン。 Magentoの準備画面が表示されます:

開始をクリックします 準備 確認 ボタン。準備チェックが完了すると、次の画面が表示されます。

次へをクリックします ボタン。データベース設定画面が表示されます:

Magentoデータベース名、データベースユーザー名、パスワードを入力し、次へをクリックします ボタン。 MagentoWeb構成ウィザードが表示されます。

Magentoストアと管理者アドレスを入力し、HTTPSを有効にして、次へをクリックします ボタン。ストアのカスタマイズ画面が表示されます:

ご希望のタイムゾーン、通貨、言語を設定し、次へをクリックします ボタン。管理者ユーザーの作成画面が表示されます:

管理者のユーザー名、メールアドレス、パスワードを入力し、次へをクリックします ボタン。次の画面が表示されます。

インストールをクリックします ボタンをクリックしてインストールを開始します。インストールが正常に完了すると、次の画面が表示されます。

Magento管理者アドレスをクリックします。 Magento管理ページが表示されます:

Magento管理者のユーザー名とパスワードを入力し、署名をクリックします ボタン。次の画面にMagentoダッシュボードが表示されます。

URLhttps://magento.linuxbuz.comを使用してMagentoストアにアクセスすることもできます。次の画面が表示されます。

結論

おめでとう!これで、Ubuntu20.04にLet'sEncryptSSLを使用してMagentoが正常にインストールされました。これで、独自のオンラインストアを簡単に展開できます。ご不明な点がございましたら、お気軽にお問い合わせください。


Ubuntu
  1. Ubuntu 20.04/18.04でLetsEncryptを使用してNginxを保護する方法

  2. ApacheとMySQLを使用したUbuntuLinuxへのWordPressのインストール

  3. Ubuntu18.04でLetsEncryptを使用してNginxを保護する

  1. Ubuntu16.04でLetsEncryptを使用してNginxを保護する

  2. Nginxを使用してNextcloudをインストールし、Ubuntu20.04LTSでSSLを暗号化する方法

  3. Nginxを使用してMagento2をインストールし、Ubuntu20.04LTSでSSLを暗号化する方法

  1. Ubuntu16.04でVarnishとApacheを使用してMagento2をセットアップする方法

  2. NGINXを使用してShopwareをインストールし、Ubuntu18.04LTSで暗号化する方法

  3. Nginxを使用してAutomadCMSをインストールし、Ubuntu18.04でSSLを暗号化できるようにします