BitNami Discourse

    Discourse is the 100% open source discussion platform with built in moderation and governance systems that let discussion communities protect themselves from trolls, spammers, and bad actors – even without official moderators. It is designed for hi-resolution tablets and advanced web browsers.

    How to start/stop the servers?

    The Stacks include a graphical tool to manage the servers easily. You can find the "manager-windows.exe", "manager-osx" or "manager-linux" tool in your installation directory. Using this tool, you can Start, Stop or Restart the servers and check the log files. You can click on the icon to start it.

    manager-servers.png

     

    manager-osx.png

     

     

     

     

     

     

     

     

     


    win_platform.png On Windows: You can also start the Manager tool from shortcuts: Start -> Program Files -> BitNami Stack -> Manager tool

     

    If you prefer, you can use the "ctlscript.sh" utility from the command line. This script is in the installation directory.

    mac_platform.png

    On OS X: You can start the Manager tool from the installation directory or you can use the "ctlscript.sh" utility from a Terminal.

    host:~ user$ cd /Applications/application-version
    host:~ user$ ./ctlscript.sh start
    

    linux_platform.png On Linux:

    $ cd ~/applicaton-version
    $ ./ctlscript.sh start
    

    How to configure SMTP settings to send emails from Discourse application?

    To configure SMTP settings using and external SMTP server, you have to add the lines indicated below to you installdir/apps/discourse/htdocs/config/environment/production.rb, for instance, after the line:

      #config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx

    The required lines to configure SMTP are the following:

      config.action_mailer.delivery_method = :smtp
      config.action_mailer.smtp_settings = {
        :address              => "SMTP_HOSTNAME",
        :port                 => SMTP_PORT,
        :domain               => 'example.com',
        :user_name            => 'SMTP_USER',
        :password             => 'SMTP_PASSWORD}',
        :authentication       => 'plain',
        :enable_starttls_auto => true  }

    Then restart the servers:

    $ sudo installdir/ctlscript.sh restart
    SMTP configuration for GMail
    Warning: If you use Discourse extensively, we recommend to use your own SMTP server for sending emails. The current GMail sending limit is 500 emails per 24 hours.

    In addition to the explanation above, an example for gmail should be as follows:

      config.action_mailer.delivery_method = :smtp
      config.action_mailer.smtp_settings = {
        :address              => "smtp.gmail.com",
        :port                 => 587,
        :domain               => 'gmail.com',
        :user_name            => 'your_user@gmail.com',
        :password             => 'your_password}',
        :authentication       => 'plain',
        :enable_starttls_auto => true  }
    SMTP configure for Mandrill

    Mandrill is a scalable and affordable email infrastructure service. You can use Mandrill to send emails through SMTP. Once you log in the application, go to the "SMTP & API" section and create an API key. 

    mandrill.png

    Below you can find an example of the Mandrill configuration settings that you should set in the "installdir/apps/discourse/htdocs/config/environment/production.rb" file:

      config.action_mailer.delivery_method = :smtp
      config.action_mailer.smtp_settings = {
        :address              => "smtp.mandrillapp.com",
        :port                 => 25,
        :domain               => 'your_domain.com',
        :user_name            => 'SMTP Username',
        :password             => 'Mandril_API_key',
        :authentication       => 'login',
        :enable_starttls_auto => true  }

    How to change the default hostname of the application?

    Once installed, Discourse is configured to be served under a concrete hostname. If you want to change it, you can use a tool named updateip placed at <installdir>/apps/discourse/updateip. To do so, it should be used by running:

    $ <installdir>/apps/discourse/updateip --machine_hostname NEW_HOSTNAME

    You can also achieve this manually. To do so, you have to set the correct hostname at <installdir>/apps/discourse/htdocs/config/database.yml and change last line of production section from:

        - "OLD_HOSTNAME"
    

    to

        - "NEW_HOSTNAME"
    
    Then restart all servers:
    $ <installdir>/ctlscript.sh restart

    If you already have any post that may need to be updated, you have to rebake all posts. To do so, you can just run the following script:

    $ <installdir>/apps/discourse/scripts/rebakeposts.sh
    

    Or do it manually:

    $ cd <installdir>
    ./use_discourse
    cd apps/discourse/htdocs
    bin/rake posts:rebake RAILS_ENV='production'

    How to upgrade Discourse?

    General procedure to upgrade the stack

    It is strongly recommended that you create a backup before starting the update process. If you have important data, it is advisable that you create and try to restore a backup to ensure that everything works properly.

    There are two different ways to upgrade your application.

    1. If you want to upgrade the application and all Stack components PHP, Ruby, MySQL, Apache… You can follow the steps described at How to upgrade the full Stack migrating the data?
    2. In case you only want to upgrade the application code without modifying any other Stack components,  you should follow the guide which is in the application page itself.

    In the Discourse case, these are the steps to migrate the database from an old version to a new one:

    • Copy the backup to the new BitNami version server. You can create a database backup in the previous server with the following command:

    ​$ pg_dump -U postgres bitnami_discourse > backup.sql 
    • Create a tarball with the upload files in the previous server and copy to the new server. You can create it with the following command:

      $ cd /home/bitnami
      $ tar -czvf uploads.tar.gz /opt/bitnami/apps/discourse/htdocs/public/uploads

       

    • Go to the new server, stop all servers and start only PostgreSQL. Note that the installation directory could be different. This is the default installation directory for Virtual Machines and Cloud images.

      $ sudo /opt/bitnami/ctlscript.sh stop
      $ sudo /opt/bitnami/ctlscript.sh start postgresql
      
    • Remove the previous database:

      $ psql -U postgres 
      drop database bitnami_discourse;
      create database bitnami_discourse;
      alter database bitnami_discourse owner to bn_discourse;
      create extension hstore; create extension pg_trgm;
      
    • Restore the new database.

      $ psql -U postgres bitnami_discourse < backup.sql
      
    • Start the Redis server and migrate the database.

      $ sudo /opt/bitnami/ctlscript.sh start redis 
      $ cd /opt/bitnami/apps/discourse/htdocs 
      $ bin/rake db:migrate RAILS_ENV=production
      
    • Restore the uploaded files in the new installation
    ​$ tar -xzvf uploads.tar.gz -C /
    
    • Restart all the servers
      $ sudo /opt/bitnami/ctlscript.sh start
      
    Keeping in sync with the Discourse repository at GitHub
    IMPORTANT: This procedure is supported since the BitNami Discourse stack 0.8.5-0 was relased on 2013-04-08.
    Since the Discourse application is changing very fast, BitNami Discourse stack includes .git files necessary to be sync with the repository.
     
    This is an advanced feature that should be used only by someone that knows the application and what is happening at every step of the process described below. If not, there is a new Discourse version available every week. Then, the standard process to upgrade the whole stack can be followed as indicated above.
     
    As some configuration parameters are adjusted during the installation, there may be some differences between the installed version and the repository even if the installer was built recently.
     
    You will need to follow the steps described below depending on the platform where your discourse is running:

    Native Installer

    • backup of the application directory should be done before moving forward.
    • Go to the installation directory and load the Stack environment
    cd <installdir>
    ./use_discourse
    
    • Stop the Apache and Sidekiq services:
    ./ctlscript.sh stop apache
    ./ctlscript.sh stop discourse_sidekiq
    
    • Stop and disable the clockwork service if your current discourse version has it:  (this is not required since version 0.9.6.1)
    ./ctlscript.sh stop discourse_clockwork 
    mv apps/discourse/clockwork.sh apps/discourse/clockwork.sh.disabled 
    • Go to the Discourse application directory
    cd apps/discourse/htdocs
    • Checkout master and pull the latest version. You will need to checkout Gemfile and Gemfile.lock to overwrite our changes to support offline installations:
    git checkout master
    git checkout Gemfile*
    git stash save
    git pull
    git stash apply
    bundle install --without development test sqlite --binstubs --deployment
    • Apply any new database migrations
    ​ruby bin/rake db:migrate RAILS_ENV=production
    
    • Recompile the application assets (it may take a few minutes)
    ruby bin/rake assets:precompile RAILS_ENV=production
    • (Deprecated) If you are running Discourse on a url with a prefix, such as http://example.com/discourse, you have to run the following command instead of the previous one:
    ruby bin/rake assets:precompile RAILS_ENV=production RAILS_RELATIVE_URL_ROOT="/discourse"
    
    • Restart Apache and the Discourse services
    <installdir>/ctlscript.sh start
     

    Cloud Image/BitNami Hosting

    • If you are using BitNami Cloud Hosting we recommend to create a backup before upgrading the application.
    • Go to the Discourse application directory
    cd /opt/bitnami/apps/discourse/htdocs
    
    • Stop the Apache and Discourse services:
    sudo /opt/bitnami/ctlscript.sh stop apache
    sudo /opt/bitnami/ctlscript.sh stop discourse_sidekiq
    • Stop and disable the clockwork service if your current discourse version has it:  (this is not required since version 0.9.6.1)
    sudo /opt/bitnami/ctlscript.sh stop discourse_clockwork
    sudo mv /opt/bitnami/apps/discourse/scripts/clockwork.sh /opt/bitnami/apps/discourse/scripts/clockwork.sh.disabled
    • Checkout master and pull the latest version. You will need to checkout Gemfile and Gemfile.lock to overwrite our changes to support offline installations: (You will need to configure git as described in the troubleshooting section below to stash the changes if it is the first time you use it)
    git checkout master
    git checkout Gemfile*
    

     

    NOTE: If you are running a linux 32-bit instance you may have problems with the gem libv8-3.16.14.3.gem because there is not any precompile version of this gem for this platform. An easy workaround could be editing the Gemfile.lock and replacing "libv8 (3.16.14.3)" with "libv8 (3.16.14.1)". Then, you can continue with the commands below:
    git stash save
    git pull
    git stash apply
    sudo bundle install --without development test sqlite --binstubs --deployment
    • Apply any new database migrations
    sudo ​/opt/bitnami/ruby/bin/ruby bin/rake db:migrate RAILS_ENV=production
    
    • Recompile the application assets (it may take a few minutes)
    sudo chmod 666 log/production.log
    sudo ​/opt/bitnami/ruby/bin/ruby bin/rake assets:precompile RAILS_ENV=production
    • (Deprecated) If you are running Discourse on an url with a prefix, such as http://example.com/discourse, you have to run the following command instead of the previous one:
    sudo ​/opt/bitnami/ruby/bin/ruby bin/rake assets:precompile RAILS_ENV=production RAILS_RELATIVE_URL_ROOT="/discourse"
    
    • Restart Apache and the Discourse services
    sudo /opt/bitnami/ctlscript.sh start
     

    Tabs end

     

    Troubleshooting
    Git command has to be configured. If you run "git" and you get this output:
    * Please tell me who you are.
    Run
    git config --global user.email "you@example.com"
    git config --global user.name "Your Name"  
    
     
    You have to execute those suggested commands to continue (you can replace generic email and generic name with the real ones):
    $ git config --global user.email "you@example.com"
    $ git config --global user.name "Your Name"
     
    Rake aborted!
    If you see the following error:
    rake aborted!
    cannot load such file -- rb-inotify
     
    Check you are runing the command using the "rake" command into the Discourse folder. Also it is necessary to use the "production" mode:
    $ export RAILS_ENV=production
    $ cd /opt/bitnami/apps/discourse/htdocs
    $ bin/rake bundle install
     
    If there is any merging conflict, it should be fixed manually, i.e.:
    $ git stash apply
    Auto-merging app/assets/javascripts/discourse/routes/discourse_location.js
    CONFLICT (content): Merge conflict in app/assets/javascripts/discourse/routes/discourse_location.js
    Auto-merging app/assets/javascripts/discourse.js
     
    Then, the files implicated must be edited. There are two options:
    1. Keep local changes. For each conflictive file:
      • Remove everything from "<<<<<<< Updated upstream" to "=======" and the line ">>>>>>> Stashed changes" 
      • Afterwards, run the following.
        git add <conflictive_file>
    • Check everything. Output of this command should be as shown:

    $ git status
    Already up-to-date.
    
    • Unstage changes automatically set to be commited.

    git reset HEAD
    1. Discard local changes. For each conflictive file:
    • Remove everything from "=======" to ">>>>>>> Stashed changes" and the line "<<<<<<< Updated upstream".

    • Afterwards, run the following.

    git add <conflictive_file>
    • Check everything. Output of this command should be as shown:

    $ git status
    Already up-to-date.
    • Unstage changes automatically set to be commited.

    git reset HEAD

    How to change the default URL to root?

    Automatic approach
    IMPORTANT: This procedure is supported since the BitNami Discourse stack 0.8.5-1 was relased on 2013-04-10.

    The  Virtual AppliancesBitNami Cloud Hosting and AMI images ship a tool called "updateip". Using this tool you be able to configure the URL automatically. It includes a new option to remove the "/discourse" prefix from the URL. If you want to modify that you can run the following command:

    $ sudo /opt/bitnami/apps/discourse/updateip --appurl /
    

    Assets need to be recompiled, so this process could take some time. Please, do not interrupt the process while it is running.

    Now you will be able to access to the Discourse application at http://example.com instead of http://example.com/discourse

    How to enable SSL on Discourse?

    You can see how to configure Apache to enable SSL connections at How to enable SSL to access through https?

    If you want to use https for all Discourse links (emails, posts, etc), it is also necessary to enable the following option in the Discourse config file /opt/bitnami/apps/discourse/htdocs/config/site_settings.yml file:

     security:
        enable_flash_video_onebox: false
        use_https: false

    The option name is different for previous versions to 0.9.8.1: "use_ssl".

    Another option is to disable plain http protocol and redirect all requests to https, you can add the following in the /opt/bitnami/apps/discourse/conf/httpd-vhosts.conf file:

    <VirtualHost *:80>
    ...
    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
    </VirtualHost>
     
    If you are not using the VirtualHost configuration, you have to add the same section in the default configuration file: /opt/bitnami/apache2/conf/bitnami/bitnami.conf file.

    How to change to development mode in Discourse?

    BitNami stacks are configured to run in production mode by default, with as less as possible dependencies. If you want to develop Discourse, you can run the applicatoin in "development" mode.

    1. Copy the database settings for production in the "development" section in the "config/database.yml" file. In this case you will use the same database instead of creating a new one. If you prefer, you can also populate a new database.

    2. Stop the Apache server:

      sudo /opt/bitnami/ctlscript.sh stop apache
      
    3. Checkout the latest Gemfile and Gemfile.lock files and install the required gems:

      cd /opt/bitnami/apps/discourse/htdocs
      git checkout Gemfile*
      sudo bundle install --without test sqlite
      
    4. Clean assets

      ruby bin/rake assets:clean
      
    5. Start the server in development mode. Instead of Apache with Passenger you can use the Thin server:

      sudo rails server -p 80
      
       

    Note that the sidekiq and clockwork servers are running in production mode by default. Maybe it is not necessary for your development but you can change the mode in the sidekiq & clockwork scripts:

    /opt/bitnami/apps/discourse/scripts/clockwork.sh

    CLOCKWORK_START="/opt/bitnami/ruby/bin/ruby $DISCOURSE_HOME/bin/clockworkd start --clock=$DISCOURSE_HOME/config/clock.rb --log --pid-dir=$CLOCKWORK_PIDDIR --log-dir=$CLOCKWORK_PIDDIR RAILS_ENV=production"

    /opt/bitnami/apps/discourse/scripts/sidekiq.sh

    SIDEKIQ_START="/opt/bitnami/ruby/bin/ruby $DISCOURSE_HOME/bin/sidekiq -P $SIDEKIQ_PIDFILE -e production -L $SIDEKIQ_LOGFILE"
    Tag page (Edit tags)
    • No tags
    Page statistics
    28679 view(s), 86 edit(s) and 22120 character(s)

    Comments

    You must login to post a comment.

    Attach file

    Attachments

    FileSizeDateAttached by 
     mandrill.png
    Mandrill SMTP configuration
    181.76 kB09:49, 11 Jul 2013AdminActions