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 ! :)

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.

×
1 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):

./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

by Justin Ellingwood
by Kathleen Juell
The Apache HTTP server is the most widely-used web server in the world. It provides many powerful features including dynamically loadable modules, robust media support, and extensive integration with other popular software. In this guide, we'll explain how to install an Apache web server on your Ubuntu 18.04 server.
  • My problem start from .discourse-setup

    First i am having error with my hostname, is example.com not allowed or is it just forum.example.com?

  • Hi @bobbyiliev.

    I’m attempting to install Discourse on the same server as LAMP to run in parallel with an HTML or WordPress frontpage. Using Ubuntu 18.04 and, of course, Apache.

    There are a few things missing from this tutorial so I filled in the blanks, starting with installing LAMP immediately after doing the initial server setup, which is really just creating a sudo user for SSH.

    Everything else, I followed closely. My frontpage currently works just fine but when visiting my Discourse forum, community.mysite.com, I get the following error:

    Proxy Error
    The proxy server received an invalid response from an upstream server.
    The proxy server could not handle the request
    
    Reason: Error reading from remote server
    

    I’m assuming there is a missing configuration somewhere. Yes, my DNS settings are correct and no, I have not installed Let’s Encrypt SSL.

    I’ve tried getting support on the Discourse forums but that was quite an undertaking that didn’t provide anything worthwhile. They just kept linking to the same two outdated tutorials from several years ago, that are designed with CentOS and Nginx in mind.

    • Hi there @orbitstorm88,

      Ah yes, that is a good point, I’ve added installation Apache to the prerequisites.

      Can you share the output of the following command:

      • sudo docker ps -a

      It sounds like that your Discourse container might not be listening on port 8080.

      Also, do you get to Discourse if you visit yourdomain.com:8080?

      Regards,
      Bobby

Submit an Answer