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?

    Graphical tool

    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

    Command line tool

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

    linux_platform.png

    On Virtual Machines and Cloud images:

    $ sudo /opt/bitnami/ctlscript.sh start

    A native installer on Linux:

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

    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

    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/discourse.conf, for instance, after the line:

    The required lines to configure SMTP are the following:

    smtp_address = "SMTP_HOSTNAME"
    smtp_port = SMTP_PORT
    smtp_domain = example.com
    smtp_user_name = 'SMTP_USER'
    smtp_password = 'SMTP_PASSWORD'
    smtp_enable_start_tls = 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:

    smtp_address = "smtp.gmail.com"
    smtp_port = 587
    smtp_domain = example.com
    smtp_user_name = 'your_user@gmail.com'
    smtp_password = 'your_password'
    smtp_enable_start_tls = true
    authentication = plain
    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/discourse.conf" file:

    smtp_address = "smtp.mandrillapp.com"
    smtp_port = 25
    smtp_domain = your_domain.com
    smtp_user_name = 'your_user@gmail.com'
    smtp_password = 'your_password'
    smtp_enable_start_tls = true
    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/bnconfig --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"
    
     
    And modify <installdir>/apps/discourse/conf/discourse.conf
    hostname = OLD_HOSTNAME
    to
    hostname = 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"
    
    • Remove the Discourse cache
    rm -rf tmp/cache    
    
    • 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"
    
    • Remove the Discourse cache
    sudo rm -rf tmp/cache
    
    • 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"

    Using a CDN

    If you are using a CDN, your users could be experiencing problems with the discourse icons if they use Firefox. To fix this error, please uncomment this lines in /opt/bitnami/apps/discourse/conf/httpd-app.conf:

    <FilesMatch "\.(ttf|otf|eot|woff|font.css)$">
        <IfModule mod_headers.c>
            Header set Access-Control-Allow-Origin "*"
        </IfModule>
    </FilesMatch>
    

    How to enable Multisite Support in Discourse?

    If you want to enable Multisite Support in Discourse you have to follow these steps (thanks

    Create a new database

    First of all, you need to create a database as well as a database user for your new site. To do so, ejecute the following commands (choose your own database_name, database_user and database_password)

    /opt/bitnami/postgresql/bin/psql -U postgres -c "CREATE DATABASE database_name;"
    /opt/bitnami/postgresql/bin/psql -U postgres -c "CREATE USER database_user; ALTER ROLE database_user WITH PASSWORD 'database_password'; GRANT ALL PRIVILEGES ON DATABASE database_name to database_user"
    /opt/bitnami/postgresql/bin/psql -U postgres -c "ALTER DATABASE database_name OWNER TO database_user;"
    /opt/bitnami/postgresql/bin/psql -U postgres -d database_name -c "CREATE EXTENSION HSTORE; CREATE EXTENSION pg_trgm;"
    
    Setup multisite.yml file

    Copy the config/multisite.yml.production-sample and modify it to use the configuration you want

    sudo cp /opt/bitnami/apps/discourse/htdocs/config/multisite.yml.production-sample /opt/bitnami/apps/discourse/htdocs/config/multisite.yml
    

    Then edit the multisite.yml file to use the database you have just created

    database_name:
      adapter: postgresql
      database: database_name
      username: database_user
      password: "database_password"
      host: /opt/bitnami/postgresql
      pool: 25
      timeout: 5000
      db_id: 2    # ensure db_id is unique for each site
      ### If you change this setting you will need to
      ###   - restart sidekiq if you change this setting
      ###   - rebake all to posts using: `RAILS_ENV=production bundle exec rake posts:rebake`
      host_names:
        - yournewhostname.com
    

    Not, just for testing, add this hostname to your /etc/hosts file

    machineIP yournewhostname.com
    

    Migrate the database

    Load the Bitnami environment and migrate the database

    sudo /opt/bitnami/use_discourse
    cd /opt/bitnami/apps/discourse/htdocs
    bin/bundle exec bin/rake multisite:migrate RAILS_ENV='production'
    
    Create an admin user

    Finally, you just need to create an admin user for your new site

    bin/rake admin:create RAILS_ENV='production' RAILS_DB=database_name
    

    And that's it, you should be able to access your new site using the new domain.


    Source: https://meta.discourse.org/t/multisi...tructions/4874

    Tag page (Edit tags)
    • No tags
    Page statistics
    41121 view(s), 94 edit(s) and 25677 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