Opencartは、完全に機能する独自のeコマースWebサイトをホストするのに役立つ人気のあるオープンソースのショッピングカートソリューションです。 Opencartは、AmazonやFlipcartなどの製品をオンラインで販売するためのシンプルでユーザーフレンドリーなインターフェースを提供します。中小企業向けに特別に設計されており、オンラインショップに必要なすべての標準的なeコマース機能を備えています。複数通貨、言語、無制限のカテゴリ、商品、商品レビュー、マルチストアなど、豊富な機能セットを提供します。
このチュートリアルでは、Debian 10にNginxを使用してOpenCartをインストールし、Let'sEncryptSSLで保護する方法を示します。
- Debian10を実行しているサーバー。
- ルートパスワードはサーバーで構成されています。
まず、次のコマンドを使用してシステムを最新バージョンに更新します。
apt-get update -y
apt-get upgrade -y
サーバーが更新されたら、サーバーを再起動して変更を適用します。
LEMPサーバーをインストールする
まず、次のコマンドを実行して、Nginx Webサーバー、MariaDBデータベースサーバー、PHP、およびその他の必要なPHP拡張機能をインストールします。
apt-get install nginx mariadb-server php-common php-cli php-fpm php-opcache php-gd php-mysql php-curl php-intl php-xsl php-mbstring php-zip php-bcmath php-soap unzip git -yを解凍します
すべてのパッケージがインストールされたら、php.iniファイルを編集して変更を加えます。
nano /etc/php/7.3/fpm/php.ini
次の行を変更します:
memory_limit = 256M upload_max_filesize = 100M opcache.save_comments=1 max_execution_time = 300 date.timezone = Asia/Kolkata
終了したら、ファイルを保存して閉じます。
MariaDBデータベースを構成する
次に、Debian 10では設定されていないため、MariaDBルートパスワードを設定する必要があります。
これを行うには、次のコマンドを使用してMariaDBシェルにログインします。
mysql
ログインしたら、次のコマンドを使用してMariaDBのrootパスワードを設定します。
MariaDB [(none)]> SET PASSWORD FOR 'root'@'localhost' = PASSWORD("yournewrootpassword");
次に、次のコマンドを使用して、MariaDB認証プラグインをmysql_native_passwordに設定します。
MariaDB [(none)]> SET GLOBAL innodb_fast_shutdown = 0;
MariaDB [(none)]> UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root';
次に、特権をフラッシュし、次のコマンドを使用してMariaDBシェルを終了します。
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
次に、rootユーザーでMariaDBにログインします:
mysql -u root -p
次のコマンドを使用して、rootパスワードを入力し、OpenCartのデータベースとユーザーを作成します。
MariaDB [(none)]> CREATE DATABASE opencartdb;
MariaDB [(none)]> GRANT ALL ON opencartdb.* TO 'opencart'@'localhost' IDENTIFIED BY 'password';
次に、特権をフラッシュし、次のコマンドを使用してMariaDBシェルを終了します。
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
MariaDBを構成したら、次のステップに進むことができます。
次のコマンドを使用して、Gitリポジトリから最新バージョンのOpenCartをダウンロードできます。
wget https://github.com/opencart/opencart/releases/download/3.0.3.2/opencart-3.0.3.2.zip
OpenCartをダウンロードした後、次のコマンドを使用してダウンロードしたファイルを解凍します。
unzip opencart-3.0.3.2.zip
次に、次のコマンドを使用して、アップロードディレクトリをNginxWebルートディレクトリに移動します。
mv upload /var/www/html/opencart
次に、ディレクトリをopencartに変更し、config-dist.phpファイルの名前を変更します。
cd /var/www/html/opencart/
mv config-dist.php config.php
mv admin/config-dist.php admin/config.php
次に、次のコマンドを使用して、opencartディレクトリに適切な権限を付与します。
chown -R www-data:www-data /var/www/html/opencart/
chmod -R 775 /var/www/html/opencart/
終了したら、次のステップに進むことができます。
OpenCart用にNginxを構成する
次に、OpenCartを提供するためのNginx仮想ホスト構成ファイルを作成する必要があります。次のコマンドで作成できます:
nano /etc/nginx/sites-available/opencart.conf
次のコンテンツを追加します:
server { listen 80; server_name opencart.linuxbuz.com; root /var/www/html/opencart; index index.php; access_log /var/log/nginx/opencart_access.log; error_log /var/log/nginx/opencart_error.log; location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.3-fpm.sock; } location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { expires max; log_not_found off; } }
ファイルを保存して閉じ、次のコマンドで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仮想ホストファイルを有効にします。
ln -s /etc/nginx/sites-available/opencart.conf /etc/nginx/sites-enabled/
次に、NginxおよびPHP-FPMサービスを再起動して、変更を適用します。
systemctl restart nginx
systemctl restart php7.3-fpm
終了したら、次のステップに進むことができます。
次に、Certbotクライアントをインストールして、WebサイトにLet'sEncryptをインストールしてセットアップする必要があります。
デフォルトでは、CertbotはDebian10のデフォルトリポジトリでは利用できません。そのため、システムにCertbotリポジトリを追加する必要があります。
次のコマンドで追加できます:
echo "deb http://ftp.debian.org/debian buster-backports main" >> /etc/apt/sources.list
次に、リポジトリを更新し、次のコマンドを使用してNginx用のCertbotクライアントをインストールします。
apt-get update -y
apt-get install python3-certbot-nginx -t buster-backports
インストールしたら、次のコマンドを実行してLet's Encrypt SSLをダウンロードし、このSSLを使用するようにNginxを構成します。
certbot --nginx -d opencart.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 opencart.linuxbuz.com Waiting for verification... Cleaning up challenges Created an SSL vhost at /etc/nginx/sites-available/opencart-le-ssl.conf Enabled Apache socache_shmcb module Enabled Apache ssl module Deploying Certificate to VirtualHost /etc/nginx/sites-available/opencart-le-ssl.conf Enabling available site: /etc/nginx/sites-available/opencart-le-ssl.conf Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
次に、以下に示すように、HTTPトラフィックをHTTPSにリダイレクトするかどうかを選択する必要があります。
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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/nginx/sites-enabled/opencart.conf to ssl vhost in /etc/nginx/sites-available/opencart-le-ssl.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://opencart.linuxbuz.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=opencart.linuxbuz.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/opencart.linuxbuz.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/opencart.linuxbuz.com/privkey.pem Your cert will expire on 2020-04-30. 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
この時点で、OpenCartはLet'sEncryptSSLで保護されています。
OpenCartWebインターフェイスにアクセス
次に、Webブラウザーを開き、URLhttps://opencart.linuxbuz.comを入力します。 OpenCartライセンス契約ページにリダイレクトされます:
続行をクリックします 使用許諾契約に同意するためのボタン。次のページが表示されます:
必要なPHP拡張機能がすべてインストールされていることを確認してから、続行をクリックします。 ボタン。次のページが表示されます:
データベースのクレデンシャル、管理者のユーザー名、パスワードを入力し、続行をクリックします ボタン。インストールが完了すると、次のページが表示されます。
次に、ターミナルを開き、次のコマンドを使用してインストールディレクトリを削除します。
rm -rf /var/www/html/opencart/install/
次に、オンラインショップに移動をクリックします 。次のページにOpenCartショップが表示されます:
次に、管理にログインをクリックします ボタン。 OpenCartログインページが表示されます:
管理者のユーザー名とパスワードを入力し、ログインをクリックします ボタン。次のページにOpenCart管理パネルが表示されます。
おめでとう!これで、Debian 10にOpenCartが正常にインストールされ、保護されました。これで、OpenCartを使用して独自のオンラインショッピングカートをホストできます。ご不明な点がございましたら、お気軽にお問い合わせください。