Debian 7 - Install Discourse

Discourse is a new style of forum that the makers of the StakcExchange network have been working on. Sites like Tek Syndicate and How-to-Geek are already using it, probably because it is fairly easy to deploy, and it appears to have a much more aesthetically pleasing look.

Note: We recommend deploying discourse on a server/VPS with at least 1 GB of RAM.

Steps

Install docker on the debian server.

Fetch Discourse

git clone https://github.com/discourse/discourse_docker.git  

Configure The Discourse App

cd discourse_docker  
cp samples/standalone.yml containers/app.yml  

Run the following set of commands to prevent exposing SSH access to the rest of the world.

SEARCH='  - "2222:22"'  
REPLACE='  - "127.0.0.1:2222:22"'  
FILEPATH="containers/app.yml"  
sed -i "s;$SEARCH;$REPLACE;" $FILEPATH  

We also need to set the hostname so that emails to users will link to the correct address. This is most noticeable with the account activation emails which will not work if you do not do this!

MY_IP_OR_HOSTNAME=[put your server's IP or full domain name here]  
SEARCH="DISCOURSE_HOSTNAME: 'discourse.example.com'"  
REPLACE="DISCOURSE_HOSTNAME: '$MY_IP_OR_HOSTNAME'"  
FILEPATH="containers/app.yml"  
sed -i "s;$SEARCH;$REPLACE;" $FILEPATH  

We need to configure ourselves to be admin with the following commands:

MY_EMAIL='[put your real email address here]'  
SEARCH="DISCOURSE_DEVELOPER_EMAILS: 'me@example.com'"  
REPLACE="DISCOURSE_DEVELOPER_EMAILS: '$MY_EMAIL'"  
FILEPATH="containers/app.yml"  
sed -i "s;$SEARCH;$REPLACE;" $FILEPATH  

Configure SMTP

If you're a Gmail user, you can create an app specific password and use that with the following set of commands to configure discourse for SMTP. If you're not a Gmail user, you can still run the commands below, but you need to lookup your SMTP details from your email provider, and you may need to change the port from 587.

PASSWORD="my gmail app specific password"  
MY_EMAIL="my_username@gmail.com"

FILEPATH="containers/app.yml"

SEARCH='DISCOURSE_SMTP_ADDRESS: smtp.example.com'  
REPLACE='DISCOURSE_SMTP_ADDRESS: smtp.gmail.com'  
sed -i "s;$SEARCH;$REPLACE;" $FILEPATH

SEARCH='#DISCOURSE_SMTP_USER_NAME: user@example.com      # (optional)'  
REPLACE="DISCOURSE_SMTP_USER_NAME: $MY_EMAIL      # (optional)"  
sed -i "s;$SEARCH;$REPLACE;" $FILEPATH

SEARCH='#DISCOURSE_SMTP_PASSWORD: pa$$word               # (optional)'  
REPLACE="DISCOURSE_SMTP_PASSWORD: $PASSWORD               # (optional)"  
sed -i "s;$SEARCH;$REPLACE;" $FILEPATH  

Build the application

Every time you reconfigure Discourse, you need to rebuild the application, which will take a long time when executed for the first time. Make sure to wait for it to complete before moving onto the next section.

./launcher rebuild app

Login

Navigate to your server's hostname or IP in your browser.

Click "Sign up", and register the email you configured as an admin before. Then check your email and click on the link. You should now be setup! You can manage your site from YOUR_HOSTNAME_OR_IP/admin.

References

Author

Programster

Stuart is a software developer with a passion for Linux and open source projects.

comments powered by Disqus