# Lange pauze bij standaardinstallatie van commando: cd /var/www/discourse & su discourse -c 'bundle install --retry 3 --jobs 4'

**URL:** https://meta.discourse.org/t/long-pause-in-standard-installation-of-command-cd-var-www-discourse-su-discourse-c-bundle-install-retry-3-jobs-4/267142
**Category:** Self-hosting
**Created:** [4 juni 2023 om 07:51 UTC](https://meta.discourse.org/t/long-pause-in-standard-installation-of-command-cd-var-www-discourse-su-discourse-c-bundle-install-retry-3-jobs-4/267142 "2023-06-04T07:51:28Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![whitewaterdeu](https://avatars.discourse-cdn.com/v4/letter/w/57b2e6/32.png) [@whitewaterdeu](https://meta.discourse.org/u/whitewaterdeu)
#### Post date: [4 juni 2023 om 10:13 UTC](https://meta.discourse.org/t/long-pause-in-standard-installation-of-command-cd-var-www-discourse-su-discourse-c-bundle-install-retry-3-jobs-4/267142/2 "2023-06-04T10:13:00Z")

</div>

Well, it is indeed a network problem, because my server is in China  
I found the resolutions, copy here in Chinese

* * *

# Installing Discourse in China [在国内环境下安装Discourse - 主页 - 第 页 - IzIy's Files - MyPress - MyPre.Cn](https://mypre.cn/2021/02/17/Discourcs-setup-on-cvm-ecs/)

Discourse version upgrades and maintenance are completed based on GitHub, and Discourse itself is written in Ruby.

Using servers like Tencent Cloud’s CVM, lightweight servers, and Alibaba Cloud’s ECS all have issues with slow access to foreign websites, mainly due to throttling operations to support domestic Git repositories.

When cloning Discourse hosted on GitHub, you can speed up access to GitHub by replacing `github.com` in the clone link with `github.com.cnpmjs.org`. For example:

Replace `git clone https://github.com/discourse/discourse_docker.git` with `git clone https://github.com.cnpmjs.org/discourse/discourse_docker.git`

In addition, when running `./discourse-setup`, the installer will also install some additional projects in Docker, such as `gem update`, which also requires adding a Ruby mirror.

You can add the Ruby mirror address by modifying the configuration file. The main files involved are `docker.git`

In addition, when running `./discourse-setup`, the installer will also install some additional projects in Docker, such as `gem update`, which also requires adding a Ruby mirror.

You can add the Ruby mirror address by modifying the configuration file. The main files involved are:

```plaintext
discourse/templates/web.template.yml
discourse/containers/app.yml

```

Before finding the place where `gem update` is called in the above files, add the following configuration for mirror sites:

```plaintext
gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
gem update bundler

```

For bundle, you can add a mirror site using `bundle config mirror.https://rubygems.org https://gems.ruby-china.com`.

Main modifications are as follows:

```diff
diff --git a/templates/web.template.yml b/templates/web.template.yml
index 28fb22d..bb0010c 100644
--- a/templates/web.template.yml
+++ b/templates/web.template.yml
@@ -86,6 +86,9 @@ run:
       cd: $home
       hook: code
       cmd:
+ - git remote -v
+ - git remote set-url origin https://github.com.cnpmjs.org/discourse/discourse.git
+ - gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
         - git reset --hard
         - git clean -f
         - git remote set-branches --add origin master
@@ -145,6 +148,7 @@ run:
       hook: web
       cmd:
         # ensure we are on latest bundler
+ - gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
         - gem update bundler
         - find $home ! -user discourse -exec chown discourse {} \\+

@@ -152,6 +156,9 @@ run:
       cd: $home
       hook: bundle_exec
       cmd:
+ - su discourse -c 'gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/'
+ - su discourse -c 'gem update bundler'
+ - su discourse -c 'bundle config mirror.https://rubygems.org https://gems.ruby-china.com'
         - su discourse -c 'bundle install --deployment --retry 3 --jobs 4 --verbose --without test developme

   - exec:
...skipping...

```

**Regarding Email Settings**

Forums usually require an email server to send various verification codes, login messages, password resets, notifications, etc.

NetEase’s free enterprise email ([ym.163.com](http://ym.163.com)) can meet this need. Using QQ Mail to enable SMTP service is also an option, or you can purchase a paid email service.

NetEase’s free enterprise email has SMTP service enabled by default. Here is an example of setting `app.yml`: Discourse does not seem to provide support for SSL connections, so we will directly use the SMTP service here. Note that the `start_tls` function needs to be explicitly disabled.

```plaintext
  DISCOURSE_SMTP_ADDRESS: smtp.ym.163.com
  DISCOURSE_SMTP_PORT: 25
  DISCOURSE_SMTP_USER_NAME: mail@getblog.cn
  DISCOURSE_SMTP_PASSWORD: "password"
  DISCOURSE_SMTP_ENABLE_START_TLS: false # (optional, default true)
  DISCOURSE_SMTP_DOMAIN: getblog.cn # (required by some providers)

```

Additionally, the website administrator’s email address should not be the same as `DISCOURSE_SMTP_USER_NAM`, otherwise, you may not receive registration emails.

# [Docker Installation of Discourse Forum/BBS System (Nginx)](https://www.bugcatt.com/archives/2529)

If you are in mainland China, you will need to set up mirror acceleration. Find the `templates` block in the configuration file and add the domestic mirror `templates/web.china.template.yml`:

```plaintext
templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/sshd.template.yml"
  - "templates/web.template.yml"
  - "templates/web.china.template.yml"

```

---

_[View the full topic](https://meta.discourse.org/t/long-pause-in-standard-installation-of-command-cd-var-www-discourse-su-discourse-c-bundle-install-retry-3-jobs-4/267142)._
