Thursday, March 19, 2015

EASY Setup Discourse on Digital Ocean Droplet (Ubuntu) - Error Help

Oh the pain! I am not a linux admin or even a self proclaimed amateur, so this has been anything but easy, but finally I was able to setup a DISCOURSE site, change the default port 80 to something else and get DISCOURSE going without the ugly customized url port showing in the URL.

This is the NOT SO SAVVY AT LINUX guide to installing DISCOURSE.

My tutorial will be a standalone, so you just have to follow what I've posted below.

STEP 01:

Follow this tutorial link (below) exactly until you get to the (Edit Discourse Configuration) step:

https://github.com/discourse/discourse/blob/master/docs/INSTALL-digital-ocean.md



Go ahead and type in (or copy paste) the command


nano containers/app.yml
and follow their advice, but you will also need to do a few things in addition to what they show you to edit in the app.yml file. Here is everything we had to uncomment (Remove the # symbol) in that file before moving on:

ORIGINAL app.yml

  - "80:80"   # fwd host port 80 to container port 80 (http)
#db_shared_buffers: "256MB"
#UNICORN_WORKERS:3 DISCOURSE_DEVELOPER_EMAILS: 'youremail@mail.com' DISCOURSE_HOSTNAME: 'discourse.example.com' DISCOURSE_SMTP_ADDRESS: smtp.example.com #(mandatory)
#DISCOURSE_SMTP_PORT: 587 #(optional)
#DISCOURSE_SMTP_USER_NAME: user@example.com #(optional)
#DISCOURSE_SMTP_PASSWORD: pa$$word #(optional)
EDITED app.yml
  - "4753:80"   # fwd host port 4753 to container port 80 (http)
db_shared_buffers: "256MB" UNICORN_WORKERS:3 DISCOURSE_DEVELOPER_EMAILS: 'myemail@email.com' DISCOURSE_HOSTNAME: 'yourdomain.com:8081' # INCLUDE PORT HERE DISCOURSE_SMTP_ADDRESS: smtp.gmail.com #(mandatory) DISCOURSE_SMTP_PORT: 587 #(optional) DISCOURSE_SMTP_USER_NAME: username@gmail.com #(optional) DISCOURSE_SMTP_PASSWORD: GMailpa$$word #(optional)

Once you have finished the edits above, save the file and exit it (as the tutorial shows you).

Then, as you continue the tutorial, you will most likely (if not, then great!) get an error when attempting to type in the first command:

./launcher bootstrap app

What I get when I type in that command is the following message:
Cannot connect to the docker daemon - verify it is running and you have access
To remedy this, you need to install apparmor... don't ask me why, but you have to... To install apparmor, type in this command:

sudo apt-get install apparmor

Then you can use the command

sudo service docker start
Now you can continue with the rest of the tutorial, starting at Bootstrap Discourse

Once you are done with the tutorial above, using your domain:8081 (with your port) you will most likely want to get rid of that port number so people don't see it or have to type it in. Step 02 shows you how to do this EASILY (as there are so many strange tutorials online that I tried them all, but only this simple process below worked seamlessly for me, 5 separate setups in a row).

However you can now access yourdomain.com:8081 with the port attached... 

STEP 02:

To get your server to recognize yourdomain.com:8081 without the port number trailing, you need to do the following (**):
cd
cd /etc/nginx/sites-enabled
nano discourse.conf
Now that you have created the discourse.conf file, you will need to edit it with your info as follows:


FILE /etc/nginx/sites-enabled/discourse.conf ***

upstream discourse {
  #fail_timeout is optional; I throw it in to see errors quickly
    server 127.0.0.1:8081 fail_timeout=5;
  }
  # configure the virtual host
  server {
    # replace with your domain name
    server_name yourdomain.com;
    location / {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      # pass to the upstream discourse server mentioned above
      proxy_pass http://discourse;
    }
  }

Once you have finished the above file and have saved it then exited the editor, then you simply need to restart nginx:

sudo service nginx stop
sudo service nginx restart

That's it! You should be all setup to then go back to the tutorial and follow the admin setup instructions from your domain name without the PORT NUMBER trailing.

This took me way too long, but the above process worked seamlessly for me! 


*** (file help)