Instructions for installing Discourse + WordPress on the same server

Installing Discourse and WordPress forums on the same server helps you save costs, take advantage of domains and subdomains…

This article guides on the new Server, will run docker and nginx, should not be done on a server with wordpress web running. (Refer from discourse).

Start step by step install Discourse + WordPress

Step 1: New server running linux (Ubuntu, CentOS)

Sure, you have to have at least 1G Ram server if you just run Discourse, because normally it costs 8-900MB. Using the same wp again, it is recommended that 4GB of ram.

If you already have a VPS running Discourse, see Step 3

Step 2: Install Discourse

See article: Instructions to install Discourse on server

Make sure Discourse is working properly.

Step 3: Stop Discourse

Pause Discourse

cd /var/discourse
./launcher stop app

Edit the app.yml file in the directory var/discourse/containers/

Find the following:

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
  - "templates/web.ssl.template.yml"
  - "templates/web.letsencrypt.ssl.template.yml"
## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see https://meta.discourse.org/t/17247 for details
expose:
  - "80:80"   # http
  - "443:443" # https

And fix it to:

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
## Uncomment these two lines if you wish to add Lets Encrypt (https)
# - "templates/web.ssl.template.yml"
# - "templates/web.letsencrypt.ssl.template.yml"
  - "templates/web.socketed.template.yml"  # <-- Added
## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see https://meta.discourse.org/t/17247 for details
expose:
# - "80:80"   # http
# - "443:443" # https

Step 4: Install Wordops + WordPress

After completing step 3, start installing Wordops then create a wordpress site. See the article to install Wordops on the server

Make sure wordpress website works normally after installing.

The settings are similar for the Webinoly script, see the instructions for installing webinoly
Successfully tested Discourse + WordPress – Webinoly on the same vps

Step 5: Create discourse.conf file

In the em directory, /etc/nginx/sites-enabled/ creates discourse.conf with the following content:

server {
    listen 80; listen [::]:80;
    server_name domain.com;  # <-- change this
    return 301 https://$host$request_uri;
}
server {
    listen 443 ssl http2;  listen [::]:443 ssl http2;
    server_name domain.com;  # <-- change this
    ssl on;
    ssl_certificate      /var/discourse/shared/standalone/ssl/domain.com.cer;  # <-- change this
    ssl_certificate_key  /var/discourse/shared/standalone/ssl/domain.com.key;  # <-- change this
    ssl_dhparam          /var/discourse/shared/standalone/ssl/dhparams.pem;
    ssl_session_tickets off;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA;
    http2_idle_timeout 5m; # up from 3m default
    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 https;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Remember to replace domain.com with your domain name.

Create dhparams.pem

openssl dhparam -out /var/discourse/shared/standalone/ssl/dhparams.pem 2048

And run the last commands:

# Make sure that Discourse isn't running
/var/discourse/launcher stop app || true
# test configuration
sudo nginx -t
# Important: If nginx -t comes back with an error, correct the config before reloading!
sudo service nginx reload
# Rebuild the container to apply changes
/var/discourse/launcher rebuild app

Now refresh Discourse and WordPress and see the results.

We will be happy to hear your thoughts

Leave a reply

DATVNN.COM
Logo
Search
Generic filters
Exact matches only
Register New Account
Reset Password
Shopping cart