Question

Need help with installing Discourse and Wordpress

  • Posted on October 18, 2014
  • jzubykAsked by jzubyk

Is there any documentation on installing Discourse Forums and Wordpress on the same server? I have Discourse running, I just need help with getting Wordpress up.

Show comments

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi!

If you provide some more details about the way you set up Discourse, it would make it much easier for us to help you. Did you use the Discourse Docker installation method? If so, the simplest way to install Discourse and Wordpress alongside each other is to use Nginx to serve Wordpress as normal with a reverse proxy to serve Discourse.

The first thing you’d need to do is configure Discourse to be served on a different port so that Nginx can bind to port 80. We’ll need to edit the Discourse configuration file, usually:

nano /var/discourse/containers/app.yml

Now find the section defining the exposed port and edit it to look like:

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

Then, rebuild Discourse:

./launcher rebuild app

Now install Nginx. You can follow this tutorial to do so and familiarize yourself with it:

Once done, you’ll need to set up a proxy pass for the Discourse instance now listening on port 8080. Edit the file /etc/nginx/sites-enabled/default to look like:

  1. upstream discourse {
  2. server 127.0.0.1:8080 fail_timeout=0;
  3. }
  4. server {
  5. listen 80 default_server;
  6. server_name my-domain.com; # Replace with your domain
  7. root /usr/share/nginx/html;
  8. index index.html index.htm;
  9. client_max_body_size 10G;
  10. location / {
  11. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  12. proxy_set_header Host $http_host;
  13. proxy_redirect off;
  14. proxy_pass http://discourse;
  15. }
  16. }

and restart Nginx with service nginx restart

Now you will be able to install Wordpress so that it runs alongside Discourse with Nginx directing requests to the right app. There’s already a great tutorial for setting up Wordpress on Nginx:

Let us know how it goes!

That did the trick! Everything is working exactly the way I want it to. Thank you!

I will link to this from the Discourse forums, if you don’t mind, as I am sure that there are other people looking for this information.

I have followed the great directions written by @asb but I can’t get Nginx to direct the requests properly.

If I access the Wordpress URL using the server name specified in default_server, I get an incomplete load of my Discourse site (shows as a blank page, but page source contains the Discourse site HTML), when I would expect to see the Wordpress site.

I can access the Wordpress admin site using the default_server URL but only if I specify a complete Wordpress URL, including the trailing index.php. Anything else I try returns the semi-broken Discourse page.

I can resolve the Discourse site, but only if I also specify the 8080 port in the URL.

Others seem to have gotten this to work, but I am stumped. Any help would be greatly appreciated!

FWIW, here is my /etc/nginx/sites-enabled/default

  1. upstream community {
  2. server 127.0.0.1:8080 fail_timeout=5;
  3. }
  4. server {
  5. listen 80 default_server;
  6. server_name www.staytuned.xyz;
  7. root /var/www/html;
  8. index index.php index.html index.htm;
  9. client_max_body_size 10G;
  10. location / {
  11. try_files $uri $uri/ /index.php?q=$uri&$args;
  12. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  13. proxy_set_header Host $http_host;
  14. proxy_redirect off;
  15. proxy_pass http://community;
  16. }
  17. error_page 404 /404.html;
  18. error_page 500 502 503 504 /50x.html;
  19. location = /50x.html {
  20. root /usr/share/nginx/html;
  21. }
  22. location ~ \.php$ {
  23. try_files $uri =404;
  24. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  25. fastcgi_pass unix:/var/run/php5-fpm.sock;
  26. fastcgi_index index.php;
  27. include fastcgi_params;
  28. }
  29. }