{"id":8848,"date":"2017-05-24T01:21:57","date_gmt":"2017-05-24T00:21:57","guid":{"rendered":"https:\/\/kb.okra.host\/article\/running-discourse\/"},"modified":"2021-04-06T14:42:50","modified_gmt":"2021-04-06T13:42:50","slug":"running-discourse","status":"publish","type":"ht_kb","link":"https:\/\/kb.okra.host\/de\/article\/running-discourse\/","title":{"rendered":"Running Discourse"},"content":{"rendered":"<p><a href=\"https:\/\/www.discourse.org\/\">Discourse<\/a> is a popular forum software written in Ruby. Because Discourse relies on Docker, which is incompatible with the platform, installation must be carried out manually. A <a href=\"https:\/\/apnscp.com\/pricing\">Pro package<\/a> is recommended to run Discourse as each worker is approximately 200 MB.<\/p>\n<h2 id=\"getting-started\" >Einstieg<\/h2>\n<p>Installation is done within the <a href=\"https:\/\/kb.apiscp.com\/terminal\/accessing-terminal\/\">Terminal<\/a>.<\/p>\n<ol>\n<li>Checkout the Discourse repository from <a href=\"https:\/\/github.com\/discourse\/discourse\">GitHub<\/a> into \/var\/www\n<pre data-language=\"shell\"><code>cd \/var\/www\r\ngit clone https:\/\/github.com\/discourse\/discourse.git\r\ncd discourse<\/code><\/pre>\n<\/li>\n<li>Verify the Ruby interpreter is at least 2.3.1. <a href=\"https:\/\/kb.apiscp.com\/ruby\/changing-ruby-versions\/\">Switch interpreters<\/a> if not.\n<pre data-language=\"shell\"><code>rvm list\r\n# Look that at least ruby-2.3.1 is the current interpreter\r\nrvm use 2.4.1<\/code><\/pre>\n<ul>\n<li>Optionally designate the Ruby version as your default Ruby interpreter for the directory:\n<pre data-language=\"shell\"><code>echo 2.4.1 &gt; .ruby-version<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li>Install Bundle and application dependencies:\n<pre data-language=\"shell\"><code>gem install bundle\r\nbundle install<\/code><\/pre>\n<ul>\n<li><span style=\"color: #0000ff\"><strong>Hinweis:<\/strong><\/span> depending upon platform, the build process will fail on the pg gem. Set the pg build configuration, then rerun <code>bundle install<\/code> to continue installation (<a href=\"https:\/\/kb.apiscp.com\/platform\/determining-platform-version\/\">v7<\/a> uses PostgreSQL 9.6, v6.5 9.4, and v6 9.1):\n<pre data-language=\"shell\"><code>bundle config build.pg --with-pg-config=\/usr\/pgsql-9.6\/bin\/pg_config<\/code><\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li>Setup <a href=\"https:\/\/kb.apiscp.com\/guides\/running-redis\/\">Redis<\/a><\/li>\n<li>Create a PostgreSQL database (<strong>Databases<\/strong> &gt; <strong>PostgreSQL Manager<\/strong>). Be sure to bump the user designated to connect to the database from the system default 5 to <em>15 concurrent connections<\/em>. Discourse pools its connections and requires a higher allowance.<\/li>\n<li>Create a new user to relay email for Discourse via <strong>Benutzer<\/strong> &gt; <strong>Benutzer hinzuf\u00fcgen<\/strong>. Ensure that the user has email privileges (incoming, outgoing) enabled.<\/li>\n<li>Copy <code>config\/discourse_defaults.conf<\/code> an <code>config\/discourse.conf<\/code>, this will provide application-specific overrides\n<pre data-language=\"shell\"><code>cp config\/discourse_defaults.conf config\/discourse.conf<\/code><\/pre>\n<\/li>\n<li>Change the following <code>config\/discourse.conf<\/code> \u00a0values to match what is on your account: db_pool (set to <code>5<\/code>), developer_emails, db_name, db_host (set to <code>127.0.0.1<\/code>), db_username, db_password, hostname, smtp_address (set to <code>localhost<\/code>), smtp_user_name, smtp_password, smtp_openssl_verify_mode (set to <code>none<\/code>), redis_port\n<ul>\n<li>developer_emails is a comma-delimited list of users that register who are conferred admin rights<\/li>\n<\/ul>\n<\/li>\n<li>Populate the database:\n<pre data-language=\"shell\"><code>RAILS_ENV=production bundle exec rake db:migrate<\/code><\/pre>\n<ul>\n<li>Migration will fail requiring the hstore, pg_trgm extensions. Open a ticket in the panel to request hstore and pg_trgm to be added to your PostgreSQL database (also include the database name). Alternatively, use <a href=\"https:\/\/kb.apiscp.com\/control-panel\/scripting-with-beacon\/\">Bake<\/a> to call <a href=\"http:\/\/docs.apnscp.com\/class-Sql_Module.html#_add_pgsql_extension\">sql_add_pgsql_extension<\/a>. Both &#8220;pg_trgm&#8221; and &#8220;hstore&#8221; are supported.<\/li>\n<\/ul>\n<\/li>\n<li>Precompile assets:\n<pre data-language=\"shell\"><code>RAILS_ENV=production bundle exec rake assets:precompile<\/code><\/pre>\n<\/li>\n<li>Create an upload storage directory under <code>\u00f6ffentlich\/<\/code>\n<pre data-language=\"shell\"><code>mkdir public\/uploads<\/code><\/pre>\n<\/li>\n<li>Dispatch Sidekiq, which handles tasks for Discourse, including sending email\n<pre data-language=\"shell\"><code>RAILS_ENV=production rvm 2.4.1 do sidekiq -L \/tmp\/sidekiq.log -P \/tmp\/sidekiq.pid -q critical -q low -q default -d<\/code><\/pre>\n<\/li>\n<li>Populate initial posts\n<pre>RAILS_ENV=production bundle exec rake posts:rebake<\/pre>\n<\/li>\n<li>Setup Passenger to serve the application:\n<pre data-language=\"shell\"><code>gem install --no-rdoc --no-ri passenger\r\npassenger-config --ruby-command<\/code><\/pre>\n<ul>\n<li>Add <code>RailsEnv production<\/code>\u00a0to your <a href=\"https:\/\/kb.apiscp.com\/guides\/htaccess-guide\/\">.htaccess <\/a>control under <code>\u00f6ffentlich\/<\/code><\/li>\n<li>Add\u00a0<a href=\"https:\/\/kb.apiscp.com\/ruby\/setting-rails-passenger\/\">PassengerRuby<\/a> directive to your\u00a0<a href=\"https:\/\/kb.apiscp.com\/guides\/htaccess-guide\/\">.htaccess<\/a>\u00a0control under <code>\u00f6ffentlich\/<\/code>, e.g.<br \/>\n<code>PassengerRuby \/home\/apnscp\/.rvm\/gems\/ruby-2.4.0\/wrappers\/ruby<\/code><\/li>\n<\/ul>\n<\/li>\n<li>Zum Schluss verbinden Sie <code>discourse\/public<\/code> zu einer <a href=\"https:\/\/kb.apiscp.com\/web-content\/creating-subdomain\/\">Subdomain<\/a> or addon domain.\n<\/p>\n<div id=\"attachment_1471\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/kb.apiscp.com\/wp-content\/uploads\/2017\/05\/add-subdomain.png\" rel=\"lightbox-0\"><img decoding=\"async\" aria-describedby=\"caption-attachment-1471\" loading=\"lazy\" class=\"size-medium wp-image-1471\" src=\"https:\/\/kb.apiscp.com\/wp-content\/uploads\/2017\/05\/add-subdomain-300x200.png\" alt=\"\" width=\"300\" height=\"200\" \/><\/a><\/p>\n<p id=\"caption-attachment-1471\" class=\"wp-caption-text\">Connecting Discourse to a subdomain named discourse.mydomain.com<\/p>\n<\/div>\n<\/li>\n<li>Visit your new Discourse forum. Register using your email address specified in <code>developer_emails<\/code>. A confirmation email will be sent if all is configured correct (smtp* settings) and Sidekiq is running. Click the link and follow the setup instructions!<span style=\"color: #0000ff\"><strong>Hinweis:<\/strong> <\/span>adding a CDN in the following section is highly recommended<\/li>\n<\/ol>\n<h2 id=\"adding-cdn\" >Adding CDN<\/h2>\n<p>Without a CDN, Discourse will serve all content through its application, which creates significant overhead. Placing a CDN in front of the static assets will allow a third-party to cache and send static content thus speeding up Discourse significantly.<\/p>\n<p>Any CDN will work. Amazon <a href=\"https:\/\/aws.amazon.com\/cloudfront\/\">CloudFront<\/a> offers 50 GB free and will be used for this example.<\/p>\n<p>Given Discourse runs on <em>discourse.mydomain.com<\/em> and the CDN will be called <em>cdn.mydomain.com<\/em>:<\/p>\n<ul>\n<li>Add a CORS header to <code>public\/.htaccess<\/code>:\n<pre>Header set Access-Control-Allow-Origin \"http:\/\/discourse.mydomain.com\"<\/pre>\n<\/li>\n<li>In CloudFront, click\u00a0<strong>Create Distribution<\/strong>\n<ul>\n<li>Select <strong>Web<\/strong><\/li>\n<li>Under <strong>Origin Domain Name<\/strong>, enter <em>discourse.mydomain.com<\/em><\/li>\n<li>Under <strong>Origin ID<\/strong>, enter <em>cdn.mydomain.com<\/em><\/li>\n<li>Under <strong>Alternative Domain Names (CNAMEs)<\/strong>, specify <em>cdn.mydomain.com<\/em><\/li>\n<li>Under <strong>Forward Headers<\/strong>, select <em>Whitelist<\/em>\n<ul>\n<li><strong>Whitelist Headers<\/strong> is now accessible. Under the header list, select <em>Origin<\/em>. Click\u00a0<strong>Add &gt;&gt;<\/strong>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>Visit <strong>DNS<\/strong> &gt; <strong>DNS Manager<\/strong>. Create a new CNAME record for cdn.mydomain.com.\n<ul>\n<li>Select <strong>CNAME<\/strong> as RR.<\/li>\n<li>Enter the <strong>CloudFront Domain Name<\/strong> as your parameter.<\/li>\n<li>Click <strong>Add<\/strong>\n<\/p>\n<div id=\"attachment_1478\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/kb.apiscp.com\/wp-content\/uploads\/2017\/05\/domain-name.png\" rel=\"lightbox-1\"><img decoding=\"async\" aria-describedby=\"caption-attachment-1478\" loading=\"lazy\" class=\"size-medium wp-image-1478\" src=\"https:\/\/kb.okra.host\/wp-content\/uploads\/2017\/05\/fb_image-1.png\" alt=\"\" width=\"300\" height=\"171\" \/><\/a><\/p>\n<p id=\"caption-attachment-1478\" class=\"wp-caption-text\">CloudFront domain field<\/p>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li>Edit <code>config\/discourse.conf<\/code>. Change\u00a0<strong>cdn_url<\/strong><\/li>\n<li><a href=\"https:\/\/kb.apiscp.com\/ruby\/restarting-passenger-processes\/\">Restart Discourse<\/a>\n<pre data-language=\"shell\"><code>touch tmp\/restart.txt<\/code><\/pre>\n<\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Discourse is a popular forum software written in Ruby. Because Discourse relies on Docker, which is incompatible with the platform, installation must be carried out manually. A Pro package is recommended to run Discourse as each worker is approximately 200 MB. Getting Started Installation is done within the Terminal. Checkout&#8230;<\/p>","protected":false},"author":1,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[66],"ht-kb-tag":[],"class_list":["post-8848","ht_kb","type-ht_kb","status-publish","format-standard","has-post-thumbnail","hentry","ht_kb_category-ruby"],"_links":{"self":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb\/8848","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/comments?post=8848"}],"version-history":[{"count":2,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb\/8848\/revisions"}],"predecessor-version":[{"id":8852,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb\/8848\/revisions\/8852"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/media\/8850"}],"wp:attachment":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/media?parent=8848"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb-category?post=8848"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb-tag?post=8848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}