jzubyk
By:
jzubyk

Need help with installing Discourse and Wordpress

October 18, 2014 5.4k views

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.

1 comment
  • Same server - different services. You probably already found the Discourse GitHub project. If you are lucky, your web service provider will have a script to set up a WordPress site. If not head on over to WordPress.org. You can download the latest version of WordPress there. Fire up your ftp client (filezilla is free for most platforms) and move your WordPress install into a new Domain folder. Have a look at Getting Started with WordPress. If you get stuck try posting to the forums.

3 Answers

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:

  • upstream discourse {
  • server 127.0.0.1:8080 fail_timeout=0;
  • }
  • server {
  • listen 80 default_server;
  • server_name my-domain.com; # Replace with your domain
  • root /usr/share/nginx/html;
  • index index.html index.htm;
  • client_max_body_size 10G;
  • location / {
  • proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  • proxy_set_header Host $http_host;
  • proxy_redirect off;
  • proxy_pass http://discourse;
  • }
  • }

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!

by Justin Ellingwood
Nginx is one of the most popular web servers in the world. It is extremely flexible and powerful and can be used to efficiently host sites and applications small or large sites and applications. In this guide we'll cover how to install and set this up on an Ubuntu 14.04 server.

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

  • upstream community {
  • server 127.0.0.1:8080 fail_timeout=5;
  • }
  • server {
  • listen 80 default_server;
  • server_name www.staytuned.xyz;
  • root /var/www/html;
  • index index.php index.html index.htm;
  • client_max_body_size 10G;
  • location / {
  • try_files $uri $uri/ /index.php?q=$uri&$args;
  • proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  • proxy_set_header Host $http_host;
  • proxy_redirect off;
  • proxy_pass http://community;
  • }
  • error_page 404 /404.html;
  • error_page 500 502 503 504 /50x.html;
  • location = /50x.html {
  • root /usr/share/nginx/html;
  • }
  • location ~ \.php$ {
  • try_files $uri =404;
  • fastcgi_split_path_info ^(.+\.php)(/.+)$;
  • fastcgi_pass unix:/var/run/php5-fpm.sock;
  • fastcgi_index index.php;
  • include fastcgi_params;
  • }
  • }
  • Hi! My answer above was mostly just setting up the Discourse side. If you want to run both together on the same server, I'd suggest using a sub-domains. For instance, this would have WordPress running on the root domain with Discourse on a sub-domain:

    • upstream community {
    • server 127.0.0.1:8080 fail_timeout=0;
    • }
    • server {
    • listen 80 default_server;
    • server_name domain.com;
    • root /var/www/html/wordpress;
    • index index.php index.html index.htm;
    • location / {
    • try_files $uri $uri/ /index.php?q=$uri&$args;
    • }
    • error_page 404 /404.html;
    • error_page 500 502 503 504 /50x.html;
    • location = /50x.html {
    • root /usr/share/nginx/html;
    • }
    • location ~ \.php$ {
    • try_files $uri =404;
    • fastcgi_split_path_info ^(.+\.php)(/.+)$;
    • fastcgi_pass unix:/var/run/php5-fpm.sock;
    • fastcgi_index index.php;
    • include fastcgi_params;
    • }
    • }
    • server {
    • listen 80;
    • server_name community.domain.com;
    • root /usr/share/nginx/html;
    • index index.html index.htm;
    • client_max_body_size 10G;
    • location / {
    • proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    • proxy_set_header Host $http_host;
    • proxy_redirect off;
    • proxy_pass http://community;
    • }
    • }
    • Thanks @asb, but it didn't work for me.

      I just installed Discourse with the Docker method, it was running but I didn't configured anything yet. Then I installed Wordpress with the tutorial on this same community:
      https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04
      And then I tried the nginx default configuration that appears above, now I have the second configuration working, the one with the Discourse forum on a subdomain. But when I try to open mydomain.com or forum.mydomain.com nothing appears ("Safari can't open the web page because he lost conection with server").

      My droplet is running Ubuntu 16.04, so I had to adjust little things when following the guides on this community.

      Thanks in advanced for your help.

      by Justin Ellingwood
      WordPress is the most popular content management system on the web. In this guide, we'll demonstrate how to install and configure it on an Ubuntu 14.04 server.
Have another answer? Share your knowledge.