CloudPanelにDiscourseをインストール

:warning: This installation method is not officially endorsed. Use at your own risk.

The Discourse team only recommend installation using the official install guide

:information_source: This is an unsupported install, appropriate for those who have experience with CloudPanel, are experienced system administrators, and comfortable with docker, reverse proxies, and have successfully completed a standard installation.

Why CloudPanel

Why might you want to install a Discourse Forum on a VPS or Dedicated Server running CloudPanel?

Here are my reasons:

I prefer to use a graphical interface for server and site administration. I’ve used most of the web hosting control panels at one time or another.

In comparison to the rest, CloudPanel is very slim and minimal and uncluttered. It has every feature I need, presented very simply and intuitively. And that’s it. It has nothing I don’t need.

I develop and host and manage many Ghost blogs, Wordpress sites, Drupal sites, and other types of sites in addition to Discourse forums. I really only need one server where I can host my Discourse forums right along side my Ghost Blogs and my Wordpress and Drupal sites. (I don’t want to pay for and maintain a separate server for each instance of Discourse.)

CloudPanel includes (right out-of-the-box) built-in Nginx and a simple interface for setting up and managing Reverse Proxies which are necessary in order to run one or more instances of Discourse on the same server or with other types of websites.

The Discourse team (and the Meta forum staff here) do not provide support for alternative server environments like Cpanel or Plesk or (as in this case) CloudPanel, or others that rise up out of the command line.

So I thought I’d share my setup and my process in case there are others who might find it useful.

[If anyone tries this method, please do let me know if/how it works out for you, or if I can improve this tutorial! :heart_eyes: ]

Install Docker

In Putty (or other terminal), from the root directory, run

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt-get install docker-ce docker-ce-cli docker-compose containerd.io

Create a Reverse Proxy Site in CloudPanel

→ We click the + Add Site button…

For my Discourse instance I am using my domain name noobish.me, so from now on wherever you see that in the rest of these instructions, replace noobish.me with your actual domain name (for example, yoursite.com)

→ We create a new “Reverse Proxy Site” in the CloudPanel for the domain where we want to host our Discourse forum (of course the DNS A record of the domain needs to be pointing to the same IP address as our CloudPanel.)

Prepare the Domain and Set up SSL

cloudflare-logo

For my site I’m using Cloudflare’s nameservers to point the domain. In Cloudflare I set the SSL to Full or Full (strict).

I also create a Cloudflare Page Rule. Visit this post to learn why.

I’m also using a free Cloudflare SSL Origin Certificate for my domain, which I “Import” into CloudPanel within the “SSL/TLS” site settings for that site (by simply pasting in both the Certificate and the Private Key I had downloaded for that domain name from my Cloudflare account.)

Install Discourse

Back in Putty (or other terminal), from the root directory (c d Enter to get back to the root) → Install the Discourse Standard Install using these commands…

git clone https://github.com/discourse/discourse_docker.git /var/discourse

Enter

cd /var/discourse

Enter

chmod 700 containers

Copy the Standalone Configuration

Now we copy the file /var/discourse/standalone.yml to /var/discourse/containers/ as app.yml before editing it according to our site settings.

cp /var/discourse/samples/standalone.yml /var/discourse/containers/app.yml

Edit the app.yml File

In addition to modifying the app.yml file according to our specific site settings, we need to change 3 more things in that file before we save it…

Under the section templates: we need to add

  - "templates/web.socketed.template.yml"

Because I’m using Cloudflare, under the section templates: I also add

  - "templates/cloudflare.template.yml"

Under the section expose: we need to comment out

  #- "80:80"   # http
  #- "443:443" # https

Under the section env: we need to add

   DISCOURSE_FORCE_HTTPS: true
For reference, you can Click Here to see the contents of my working app.yml on noobish.me where I'm using both Cloudflare and Mailgun...
## this is the all-in-one, standalone Discourse Docker container template
##
## After making changes to this file, you MUST rebuild
## /var/discourse/launcher rebuild app
##
## BE *VERY* CAREFUL WHEN EDITING!
## YAML FILES ARE SUPER SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT!
## visit http://www.yamllint.com/ to validate this file as needed

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
  - "templates/web.socketed.template.yml"
  - "templates/cloudflare.template.yml"

params:
  db_default_text_search_config: "pg_catalog.english"

  ## Set db_shared_buffers to a max of 25% of the total memory.
  ## will be set automatically by bootstrap based on detected RAM, or you can override
  db_shared_buffers: "4096MB"

  ## can improve sorting performance, but adds memory usage per-connection
  #db_work_mem: "40MB"

  ## Which Git revision should this container use? (default: tests-passed)
  #version: tests-passed

env:
  LC_ALL: en_US.UTF-8
  LANG: en_US.UTF-8
  LANGUAGE: en_US.UTF-8
  # DISCOURSE_DEFAULT_LOCALE: en

  DISCOURSE_FORCE_HTTPS: true

  ## How many concurrent web requests are supported? Depends on memory and CPU cores.
  ## will be set automatically by bootstrap based on detected CPUs, or you can override
  UNICORN_WORKERS: 8

  ## TODO: The domain name this Discourse instance will respond to
  ## Required. Discourse will not work with a bare IP number.
  DISCOURSE_HOSTNAME: 'noobish.me'

  ## Uncomment if you want the container to be started with the same
  ## hostname (-h option) as specified above (default "$hostname-$config")
  #DOCKER_USE_HOSTNAME: true

  ## TODO: List of comma delimited emails that will be made admin and developer
  ## on initial signup example 'user1@example.com,user2@example.com'
  DISCOURSE_DEVELOPER_EMAILS: 'admin@noobish.me'

  ## TODO: The SMTP mail server used to validate new accounts and send notifications
  # SMTP ADDRESS, username, and password are required
  # WARNING the char '#' in SMTP password can cause problems!
  DISCOURSE_SMTP_ADDRESS: smtp.mailgun.org
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: postmaster@noobish.me
  DISCOURSE_SMTP_PASSWORD:  pYdRLyQW
  #DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)
  #DISCOURSE_SMTP_DOMAIN: noobish.me    # (required by some providers)
  DISCOURSE_NOTIFICATION_EMAIL: noreply@noobish.me    # (address to send notifications from)

  ## The http or https CDN address for this Discourse instance (configured to pull)
  ## see https://meta.discourse.org/t/14857 for details
  #DISCOURSE_CDN_URL: https://discourse-cdn.example.com

  ## The maxmind geolocation IP address key for IP address lookup
  ## see https://meta.discourse.org/t/-/137387/23 for details
  #DISCOURSE_MAXMIND_LICENSE_KEY: 1234567890123456

## The Docker container is stateless; all data is stored in /shared
volumes:
  - volume:
      host: /var/discourse/shared/standalone
      guest: /shared
  - volume:
      host: /var/discourse/shared/standalone/log/var-log
      guest: /var/log

## Plugins go here
## see https://meta.discourse.org/t/19157 for details
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git

## Any custom commands to run after building
run:
  - exec: echo "Beginning of custom commands"
  ## If you want to set the 'From' email address for your first registration, uncomment and change:
  ## After getting the first signup email, re-comment the line. It only needs to run once.
  #- exec: rails r "SiteSetting.notification_email='info@unconfigured.discourse.org'"
  - exec: echo "End of custom commands"

Then we save and exit the app.yml file…

CTRL-X

y

Enter

Next we set the permissions for the app.yml file…

chmod o-rwx containers/app.yml

then…

Bootstrap the App

cd /var/discourse
./launcher bootstrap app

This will take a considerable amount of time. In the end of the bootstrap process, you’ll be asked to:

./launcher start app

Edit the Vhost File

Now we go back into our CloudPanel and paste the below code into the “Vhost Editor” for our Discourse site (overwriting what is already there). Of course replace yoursite.com with your actual domain name.

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  {{ssl_certificate_key}}
  {{ssl_certificate}}
  server_name yoursite.com;
  {{root}}

  {{nginx_access_log}}
  {{nginx_error_log}}

  if ($scheme != "https") {
    rewrite ^ https://$host$uri permanent;
  }

  location ~ /.well-known {
    auth_basic off;
    allow all;
  }

  {{settings}}

  add_header Cache-Control no-transform;

  location / {
                proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock:;
                proxy_set_header Host $http_host;
                proxy_http_version 1.1;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Real-IP $remote_addr;

  }
}

Restart Nginx

Next we need to restart Nginx, which we can do by clicking a button in the Admin Area of the CloudPanel…

Congratulations!

Now, in our browser, we can go to our site’s URL and run the Discourse Setup Wizard…

Cohabitate Peacefully

Now I can self-host and manage my Discourse site right along side my Ghost, Wordpress, Drupal and other types of sites using a clean and lean management panel, with minimal need going forward to use the terminal/command line.


To Install Additional Discourse Instances…

「いいね!」 3

これらの手順を削除し、このエラーを生成せずに app.yml を作成する必要があります。混乱します。

(ファイル全体を置き換えるのであれば、なぜ例をコピーするのですか?)既存のサンプルから何を変更する必要があるかを言う方が良いでしょう。ソケットテンプレートと強制 HTTPS のようです。

これにより、2 つの postgres コピーが使用され、1 つの postgres よりも多くの RAM を消費します。機能しますが、ベストプラクティスではありません。

この例がフォローするのに適していない理由はいくつかあり、サポートが非常に困難になります。ご自身で解決策を見つけられたことは嬉しいですが、人々をこの道に進ませるのは良いことではないと思います。

「いいね!」 3

@pfaffman --ありがとうございます。

おっしゃる通りです。目的は達成できますが、手順が煩雑すぎます。順序も間違っています。ご提案に感謝いたします。修正します。

なぜそう思われるのか、明確にしていただけますか?

なぜなら、それは複雑であり、自分で理解できる人にとってのみ良い考えだからです。それはかなり無駄が多く、単に2つのディスコースを実行することが目標である場合、ほとんどの場合、2つの別々のVMの方が安価で簡単なソリューションです。

「いいね!」 2

改めて @pfaffman さん、ありがとうございます。手順を簡略化し、同じサーバーに2つ目のDiscourseサイトを追加するセクションを削除しました。

「いいね!」 1

このメッセージを受け取りました

sudo apt update
sudo apt-get install docker-ce docker-ce-cli docker-compose containerd.io
usage: gpg [options] --dearmor [file]
curl: (23) Failed writing body

なぜですか?

アントニオさん、こんにちは。ようこそ。

これはDiscourseの問題ではなく、Dockerの問題のようです。OSとdocker-ceのアップデートで検索した方が、ここで質問するよりも良い結果が得られるでしょう。

Discourseを使おうとしていますか?それともCloudPanelですか?

「いいね!」 1

ガイドに従ったばかりです。Dockerインストールの最初のコマンドを実行したところ、サーバーから次のような応答がありました。
コマンドは次のとおりです。

「いいね!」 1

各行末のバックスラッシュは不要です。バックスラッシュは改行をエスケープし、シェルは次の行を同じ行の継続として扱います。

この場合、単一のコマンドとして実行しようとするため、エラーが発生しています。
sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg echo \"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable\"

行末のバックスラッシュを削除するだけで解決します。

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable\" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt-get install docker-ce docker-ce-cli docker-compose containerd.io
「いいね!」 2

ありがとうございます、これで正常に動作します

「いいね!」 2

@Simon_Manning 様、ありがとうございます。トップ投稿チュートリアルのコードスニペットからバックスラッシュを削除しました。

「いいね!」 2

申し訳ありません、このエラーが発生しました: FAILED

Pups::ExecError: /usr/local/bin/ruby -e 'if ENV["DISCOURSE_SMTP_ADDRESS"] == "smtp.example.com"; puts "Aborting! Mail is not configured!"; exit 1; end' failed with return #<Process::Status: pid 112 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params "/usr/local/bin/ruby -e 'if ENV[\"DISCOURSE_SMTP_ADDRESS\"] == \"smtp.example.com\"; puts \"Aborting! Mail is not configured!\"; exit 1; end'"
bootstrap failed with exit code 1
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.
./discourse-doctor may help diagnose the problem.
214c73c4474ed59e7b6fb7f42143ce126d2b453022b08770da3af31ca2fdaaba

CloudPanel は知りませんが、エラーメッセージは自己説明的なようです。

'if ENV["DISCOURSE_SMTP_ADDRESS"] == "smtp.example.com"; puts "Aborting! Mail is not configured!"; exit 1; end'
'if ENV[\"DISCOURSE_SMTP_ADDRESS\"] == \"smtp.example.com\"; puts \"Aborting! Mail is not configured!\"; exit 1; end'\"

./discourse-setup の実行中、または app.yml (いつでも手動で編集できます) 内でメールが設定されていなかったようです。 :thinking:

「いいね!」 2

皆さん、こんにちは。私はフェルミ高校の教授で、学校のためにディスコースコミュニティをインストールしようとしています。クラウドパネルを使用しているので、このガイドに従いましたが、何かが足りないようです。助けていただき、より詳細なガイドを提供していただけますか?どうぞよろしくお願いします。

「いいね!」 1

sysadminの知識があまりない場合、高度なインストールは求めているものではないと思います。もう一つ考慮すべき重要な点は、そのようなインストールは#unsupported-installの対象となり、問題が発生した場合にここで助けてもらえる可能性が低くなることです。

予算があり、コミュニティの規模によっては、別のサーバーでDiscourseをホストし、標準のインストールに従う方が良いかもしれません。

「いいね!」 1

申し訳ありませんが、このようなサービスは何のためにあるのでしょうか? 私の意見では、ガイドはあまり詳細ではなく、システム管理者向けに作られているようです。単にさまざまな手順を示すだけで十分でしょう。私が育ったところでは、「誰も教育を受けて生まれてくるわけではない」と言われています。ご協力とご尽力に感謝いたします。

「いいね!」 1

まさにその通りです。だからこそ、標準インストールをお勧めしたのです。

そして、@denvergeeks、だからこそ、私は最初からこのようなガイドを作成するのは良い考えだと思わなかったのです。書くのも、維持するのも大変で、確認できるのはあなただけです。

「いいね!」 4

申し訳ありませんが、同意できません。すでにさまざまなドメインでクラウドパネルを使用しています。さらに、ディスコースコミュニティはサブドメインで実行され、著者の前提は非常に明確です(ガイドは、VPSにさまざまなサービスがインストールされているクラウドパネルを使用しているユーザー向けです)。すべてをより詳細に説明するには、少しの努力が必要です。結局のところ、知識の共有はコミュニティの基盤です。そうでなければ、すでにインストールされてすぐに使用できるソフトウェアを購入したでしょう。いずれにしても、誰かを悩ませたくありません。助けが得られるなら感謝しますが、そうでなければ二度と邪魔しません。

「いいね!」 1

@denvergeeks メール設定は通常の運用に不可欠であり、標準のインストールへのリンクはありますが、現在のガイドの記述方法は、メール設定や特定のセットアップに重要となる可能性のあるその他のさまざまな情報を回避しています。

「Discourseのインストール」から「アプリのブートストラップ」までのセクションを、次のようなものに置き換える価値があるかどうか疑問に思います。

Discourseのインストールと設定

標準のインストール手順のステップ1〜6に従ってください。

<現在の「アプリ.ymlファイルの編集」セクションの内容を実行してください>

Discourseを再構築します。

./launcher rebuild app

その後、「おめでとうございます!」セクションで、スクリーンショットの後に、「標準のインストールドキュメントの残りの部分を続行してください。」のような一文を追加します。基本的に、ガイドを再構築して、代替のインストール手順を提供するのではなく、標準のインストールを補完する追加の手順を提供します。

CloudPanelに関する提供された情報は非常に役立ち、手順も明確だと思います。Discourse側は、標準のインストールからの逸脱を減らすことで、より安全になり、unsupported-install タグを付けることで、そこには危険があることが(より)明確になるという点で、さらに改善される可能性があります。

「いいね!」 2

議論は元のトピックから少し逸れていますが、喜んでお手伝いさせていただきますのでご安心ください。 :slight_smile:

要約すると、次のようになります。

基本的なIT知識があれば、標準のインストールに従うことができます。また、ドメイン名が必要であり、Mailgunのようなメール送信サービスを設定する必要があります(チュートリアルはこちら:Configure Mailgun for email when using Digital Ocean for DNS

通常、このフォーラムの範囲外の事項についてはお手伝いしないことに注意してください。たとえば、「ドメイン名の登録方法は?」という質問はここには当てはまりません。

基本的なIT知識がなく、予算に応じて、Marketplace で有料サポートを依頼できます。

最後に、Discourseのマネージド有料プランも検討できます。このプランでは、ほぼすべてのことが私たちによって処理され、チームサポートにアクセスできます。

また、学校のために言及されているので、教育目的で割引を提供していることも知っておいてください。

教育機関または非営利団体向けの割引はありますか?

はい!法的に認められた教育機関であれば、85%の割引を提供しています。法的に認められた連邦税免除の非営利団体であれば、50%の割引を提供しています。これらの割引は、基本、プロ、ビジネスプランにのみ適用され、他の割引と組み合わせることはできません。また、月払いまたは年払いのデビット/クレジットカードで支払う必要があります。[トライアル開始後、お問い合わせいただければ、アカウントに割引を追加します。

「いいね!」 4