このチュートリアルでは、Debian 11にMemcachedをインストールする方法を紹介します。知らない人のために、高性能の分散メモリオブジェクトキャッシングシステムであるMemcachedはデータベースの負荷を軽減することで動的なWebアプリケーションを高速化するのに非常に役立ちます。これにより、外部データソースを読み取る必要がある回数が減り、オーバーヘッドが削減され、応答時間が短縮されます。メモリキャッシュソフトウェアは、誰でも利用できる無料のオープンソースプロジェクトです。使用できます。
この記事は、少なくともLinuxの基本的な知識があり、シェルの使用方法を知っていること、そして最も重要なこととして、サイトを独自のVPSでホストしていることを前提としています。インストールは非常に簡単で、ルートアカウントで実行されていますが、そうでない場合は、'sudo
を追加する必要があります。 ルート権限を取得するコマンドに‘。 Debian 11(Bullseye)にMemcachedを段階的にインストールする方法を紹介します。
前提条件
- 次のオペレーティングシステムのいずれかを実行しているサーバー:Debian 11(Bullseye)。
- 潜在的な問題を防ぐために、OSの新規インストールを使用することをお勧めします。
non-root sudo user
またはroot user
へのアクセス 。non-root sudo user
として行動することをお勧めします ただし、ルートとして機能するときに注意しないと、システムに害を及ぼす可能性があるためです。
Debian11BullseyeにMemcachedをインストールする
ステップ1.ソフトウェアをインストールする前に、次のapt
を実行して、システムが最新であることを確認することが重要です。 ターミナルのコマンド:
sudo apt update sudo apt upgrade
ステップ2.Debian11にMemcachedをインストールします。
デフォルトでは、MemcachedはベースのDebian 11リポジトリで利用できます。次に、次のコマンドを実行してインストールします。
sudo apt install memcached libmemcached-tools
インストール後、Memcachedサービスが自動的に開始されます。サービスのステータスを確認することで確認できます:
sudo systemctl status memcached
手順3.Memcachedを構成します。
Memcached構成ファイルは/etc/memcached.conf
です。 次のコマンドを実行して、Memcached構成を変更できます。
sudo nano /etc/memcached.conf
以下のファイルで、localhost IP 127.0.0.1を見つけて、実際のサーバーIPに置き換えます。
# memcached default config file # 2003 - Jay Bonci <[email protected]> # This configuration file is read by the start-memcached script provided as # part of the Debian GNU/Linux distribution. # Run memcached as a daemon. This command is implied, and is not needed for the # daemon to run. See the README.Debian that comes with this package for more # information. -d # Log memcached's output to /var/log/memcached logfile /var/log/memcached.log # Be verbose # -v # Be even more verbose (print client commands as well) # -vv # Start with a cap of 64 megs of memory. It's reasonable, and the daemon default # Note that the daemon will grow to this size, but does not start out holding this much # memory -m 256 # Default connection port is 11211 -p 11211 # Run the daemon as root. The start-memcached will default to running as root if no # -u command is present in this config file -u memcache # Specify which IP address to listen on. The default is to listen on all IP addresses # This parameter is one of the only security measures that memcached has, so make sure # it's listening on a firewalled interface. -l 127.0.0.1 # Limit the number of simultaneous incoming connections. The daemon default is 1024 # -c 1024 # Lock down all paged memory. Consult with the README and homepage before you do this # -k # Return error when memory is exhausted (rather than removing items) # -M # Maximize core file limit # -r # Use a pidfile -P /var/run/memcached/memcached.pid
ファイルを保存して閉じます。次に、Memcachedプロセスを再起動して有効にします:
sudo systemctl restart memcached
手順4.ファイアウォールを構成します。
UFWがインストールされている場合は、ポート11211でUFW許可ルールを作成する必要があります:
sudo ufw allow proto tcp from <your ip address> to any port 11211 sudo ufw reload
ステップ5.Memcachedを使用します。
PHP、Pythonなどのプログラミング言語で使用できるMemcachedクライアントは多数あります。ただし、MemcachedをPHPアプリケーションのキャッシングシステムとして使用するには、 WordPress、PHP用の拡張機能であるMemcachedをインストールする必要があります:
sudo apt install php-memcached
おめでとうございます!Memcachedが正常にインストールされました。Debian11Bullseyeに最新バージョンのMemcachedをインストールするためにこのチュートリアルを使用していただき、ありがとうございます。追加のヘルプや役立つ情報については、Memcachedの公式Webサイトを確認することをお勧めします。 。