By BlackBelt35
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 ! :)
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!
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:
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:
To install Docker please follow the steps here:
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04
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
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.
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:
- 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.
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>
a2ensite forum.example.com
a2enmod proxy
a2enmod proxy_http
a2enmod proxy_balancer
a2enmod lbmethod_byrequests
systemctl restart apache2
And after that, you would be able to access Discourse directly via your domain name.
Hope that this helps! Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.