この記事では、Debian9VPSにApacheCouchDBをインストールする方法を紹介します。
Apache CouchDBは、JSONを使用してデータを格納する無料のオープンソースのNoSQLドキュメント指向データベースソリューションです。 CouchDBは、書き込み時にデータベースファイルをロックしないため、モバイルレプリケーションおよび同期デバイスで一般的に使用されます。 CouchDBには、管理が容易なWebベースの管理コンソールも付属しており、簡単なホットバックアップ、フォールトトレラントエンジン、ユーザーデータの保護などをサポートしています。インストールから始めましょう。
ステップ1:SSH経由でログインし、システムを更新する
rootユーザー(またはsudo権限を持つユーザー)としてSSH経由でDebian 9 VPSにログインします:
ssh root@Server_IP_Address -p Port_Number
もちろん、 Server_IP_Address
を置き換える必要があります およびPort_Number
実際のサーバーのIPアドレスとSSHポート番号を使用します。
次のコマンドを実行すると、システムに現在インストールされているすべてのパッケージが更新され、利用可能な最新バージョンにアップグレードされます。
apt update && apt upgrade -y
ステップ2:Webサーバーをインストールする
まず、CouchDBを実行するためにWebサーバーをインストールする必要があります。 Debian 9で利用可能な任意のWebサーバーを選択して、サーバーにインストールできます。ただし、このチュートリアルでは、NginxをWebサーバーとして使用してインストールします。次のコマンドを実行すると、NginxWebサーバーをVPSにインストールできます。
apt install nginx
インストールが完了したら、これらのコマンドを使用してNginxを起動し、サーバーの起動時に起動できるようにすることができます。
systemctl start nginx systemctl enable nginx
ここで、CouchDBを正しく正常にインストールするために必要ないくつかの依存関係もインストールします。
apt-get install apt-transport-https curl -y
ステップ3:CouchDBリポジトリをダウンロード/有効化
残念ながら、CouchDBは、Debian 9にあるプレインストールされたリポジトリでは利用できません。代わりに、次のコマンドを使用して、公式のApacheCouchDBリポジトリを追加します。
echo "deb https://apache.bintray.com/couchdb-deb stretch main" \ | sudo tee -a /etc/apt/sources.list
それが完了したら、次のコマンドを使用してリポジトリのキーを追加できます。
curl -L https://couchdb.apache.org/repo/bintray-pubkey.asc \ | sudo apt-key add -
これで、新しくインストールしたリポジトリを使用してCouchDBをインストールできます。
ステップ4:CouchDBをインストールする
前の手順でCouchDBリポジトリを有効にしたので、リポジトリキャッシュを更新し、ApacheCouchDBパッケージをインストールする必要があります。
apt-get update && apt-get install couchdb
インストール中に、スタンドアロンまたはクラスター化のどちらのタイプのインストールを選択するかを確認するメッセージが表示されます。
┌──────────────────────────┤ Configuring couchdb ├──────────────────────────┐ │ │ │ Please select the CouchDB server configuration type that best meets your │ │ needs. │ │ │ │ For single-server configurations, select standalone mode. This will set │ │ up CouchDB to run as a single server. │ │ │ │ For clustered configuration, select clustered mode. This will prompt for │ │ additional parameters required to configure CouchDB in a clustered │ │ configuration. │ │ │ │ If you prefer to configure CouchDB yourself, select none. You will then │ │ need to edit /opt/couchdb/etc/vm.args and /opt/couchdb/etc/local.d/*.ini │ │ yourself. Be aware that this will bypass *all* configuration steps, │ │ including setup of a CouchDB admin user - leaving CouchDB in "admin │ │ │ │ General type of CouchDB configuration: │ │ │ │ standalone │ │ clustered │ │ none │ │ │ │ <Ok> │ | | └───────────────────────────────────────────────────────────────────────────┘
このチュートリアルでは、スタンドアロンタイプを選択します。特定のユースケースによっては、「クラスター化」を選択する必要がある場合があることに注意してください。ほとんどの場合、必要なのは「スタンドアロン」バージョンのCouchDBのみです。それを選択し、[Enter]キーを押して続行します。次に、インターフェイスバインドアドレスを選択するように求められます。デフォルトのインストールオプションを選択します。
┌─────────────────────────┤ Configuring couchdb ├──────────────────────────┐ │ A CouchDB node must bind to a specific network interface. This is done │ │ via IP address. Only a single address is supported at this time. │ │ │ │ The special value '0.0.0.0' binds CouchDB to all network interfaces. │ │ │ │ The default is 127.0.0.1 (loopback) for standalone nodes, and 0.0.0.0 │ │ (all interfaces) for clustered nodes. In clustered mode, it is not │ │ allowed to bind to 127.0.0.1. │ │ │ │ CouchDB interface bind address: │ │ │ │ 127.0.0.1_______________________________________________________________ │ │ │ │ <Ok> │ │ │ └──────────────────────────────────────────────────────────────────────────┘
次に、CouchDB管理者ユーザーの新しいパスワードを選択する必要があります:
┌─────────────────────┤ Configuring couchdb ├────────────────────────┐ │ It is highly recommended that you create a CouchDB admin user, │ ││ │ which takes CouchDB out of the insecure "admin party" mode. │ ││ │ Entering a password here will take care of this step for you. │ │ │ │ If this field is left blank, an admin user will not be created. │ │ │ │ A pre-existing admin user will not be overwritten by this package. │ │ │ │ Password for the CouchDB "admin" user: │ │ │ │ *************_____________________________________________________ │ │ │ │ <Ok> │ │ │ └────────────────────────────────────────────────────────────────────┘
パスワードをもう一度入力します:
┌────────────┤ Configuring couchdb ├─────────────┐ │ │ │ │ │ Repeat password for the CouchDB "admin" user: │ │ │ │ ************__________________________________ │ │ │ │ <Ok> │ │ │ └────────────────────────────────────────────────┘
インストールが完了したら、新しいCouchDBインスタンスを起動し、起動時に起動できるようにします:
systemctl start couchdb systemctl enable couchdb
ステップ5:Nginxを設定する
ドメインまたはサブドメインを使用してブラウザーでApacheCouchDBにアクセスするには、リバースプロキシを使用してNginx構成ファイルを作成する必要があります。テキストエディタとしてnanoを使用し、CouchDB構成ファイルを作成します:
nano /etc/nginx/sites-available/couchdb.conf
次の構成を新しいcouchdb.confファイルに挿入します。 domain-name.comを実際のドメインに変更することを忘れないでください。
server { listen 80; server_name domain-name.com; server_name_in_redirect off; proxy_set_header Host $host:$server_port; location / { proxy_pass http://127.0.0.1:5984; proxy_redirect off; proxy_buffering off; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
編集が完了したら、ファイルを保存して閉じます。この構成を有効にするには、次のコマンドを実行します。
ln -s /etc/nginx/sites-available/couchdb.conf /etc/nginx/sites-enabled/
次のコマンドを使用して、Nginx構成ファイルの正しい構文をテストできます。
nginx -t
または
service nginx configtest
テストに合格したら、Webサーバーを再起動して、行った変更を含めます。
systemctl restart nginx
ステップ6:CouchDBWebインターフェースにアクセスする
前の手順に注意深く従えば、 http://domain-name.com/_utils/
にアクセスできるはずです。 お好みのウェブブラウザで「Fauxton」と呼ばれるCouchDBのウェブベースのインターフェース。
CouchDBインスタンスにログインするには、インストール中に定義した資格情報を使用できます。それでおしまい!これで、完全に機能するCouchDBサーバーがセットアップされました。
もちろん、Linux VPSホスティングプランのいずれかを使用している場合は、Debian 9にCouchDBをインストールする必要はありません。その場合は、専門のLinux管理者にすべての設定を依頼するだけです。 24時間年中無休でご利用いただけます。リクエストはすぐに処理されます。
PS。 Debian 9にCouchDBをインストールする方法に関するこの投稿が気に入った場合は、下のボタンを使用してソーシャルネットワークを介して友達と共有するか、コメントセクションにコメントを残してください。ありがとう。