Question

Install Discourse on a droplet with WordPress served by Apache ?

Hello everyone ! :) I’m really puzzled by a little problem with my personnal website project : I can’t manage to install any Discourse instance on my droplet, with already WordPress and Apache installed.

I know there are already many threads for this. But they don’t exactly fit to my case : Install Discourse in a Docker container, with Apache used to serve WordPress.

For example, this thread is for installing WordPress on a droplet with Discourse. But I need the reverse : https://www.digitalocean.com/community/questions/need-help-with-installing-discourse-and-wordpress

And this one is for installing Discourse on a droplet / server with WordPress served by Nginx. But my WordPress is served by Apache : https://blog.khophi.co/install-run-discourse-behind-nginx-right-way-first-time/

So it doesn’t fit to my situation.

The manipulations are probably 95% similar between Apache and Nginx, but I don’t want to do any mistake.

I could use a separate droplet for Discourse, but I need to use Discourse’s API to share its database with a custom social network app, created by the main programmer of my project. And it also uses a JSON add-on installed on the WordPress instance.

So it will be way simplier if I can install all that stuff on the same droplet. Without any conflicts.

  • Apache is listening to port 80.

  • My droplet uses Ubuntu 18.04.

  • Discourse will be installed on a subdomain : forum.example.com. DNS records are already done.

Any tips or suggestions are welcome ! :)


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
February 4, 2020
Accepted Answer

Hello,

This is a really good question.

I’ve tried to replicate your setup and create a step by step guide on how to set Discourse on a Droplet with Apache and an existing Wordpress installation. To be honest it took me a while to figure the whole process out.

Here are the steps that you would need to take:

Prerequisites

  • To be on the safe side make sure to backup your Droplet, so that in case anything goes wrong, you could revert back to a working version

  • SSH to your Droplet

  • Apache installed, you can follow the steps on how to do that here:

https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04

Step 1 - Install Docker

To install Docker please follow the steps here:

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04

Step 2 - Download Discourse

First, create a directory where you would store your Discourse files:

mkdir /var/discourse

After that clone the official Discourse Docker Image into /var/discourse.

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

Step 3 - Configure Discourse to listen on port 8080

We will use the standalone.yml template it includes all of the necessary services like PostgreSQL, Redis and etc.

You copy the sample file with the following command:

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

After that edit the file with your favorite editor. Open the /var/discourse/containers/app.yml and update and the ports on lines 23 and 24:

## which TCP/IP ports should this container expose?
expose:
  - "8080:80"   # fwd host port 8080   to container port 80 (http)
  - "8443:443"   # fwd host port 8443 to container port 443 (http)

Also if you do not yet have an SSL certificate make sure to comment line 16 out:

  #- "templates/web.ssl.template.yml"

Just add the # symbol in front of the - "templates/web.ssl.template.yml line otherwise Discourse would not start.

Step 4 - Setup Discourse

Then, start Discourse (as this is the first time that you are starting the service it would bootstrap the application with the new changes that you have in your app.yml file):

First cd to the /var/discourse directory:

  1. cd /var/discourse`

Then run the following setup command:

./discourse-setup

Note: Make sure to provide valid Mail server settings as otherwise, the setup might fail.

Step 5 - Setup Apache

In your /etc/apache2/sites-available/ create a new file called forum.example.com.conf and add the following Vhost content:

<VirtualHost *:80>
  ServerName forum.example.com
  ServerAlias www.forum.example.com

  <IfModule proxy_module>
    ProxyPreserveHost on
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/
  </IfModule>
</VirtualHost>
  • Enable the Vhost with the following command:
a2ensite forum.example.com
  • Enable Mod Proxy:
a2enmod proxy
a2enmod proxy_http
a2enmod proxy_balancer
a2enmod lbmethod_byrequests
  • Restart Apache:
systemctl restart apache2

And after that, you would be able to access Discourse directly via your domain name.

Hope that this helps! Regards, Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel