Bitnami Discourse Installer

NOTE: Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and Mac OS X) or by clicking the shortcut in the Start Menu under "Start -> Bitnami APPNAME Stack -> Application console" (Windows). Learn more.
NOTE: When running the commands shown on this page, replace the installdir placeholder with the full installation directory for your Bitnami stack.

Description

Discourse is an open source discussion platform with built-in moderation and governance systems that let discussion communities protect themselves from bad actors even without official moderators.

First steps with the Bitnami Discourse Stack

Welcome to your new Bitnami application! Here are a few questions (and answers!) you might need when first starting with your application.

What are the system requirements?

Before you download and install your application, check that your system meets these requirements.

How do I install the Bitnami Discourse Stack?

Windows, OS X and Linux installer
  • Download the executable file for the Bitnami Discourse Stack from the Bitnami website.

  • Run the downloaded file:

    • On Linux, give the installer executable permissions and run the installation file in the console.
    • On other platforms, double-click the installer and follow the instructions shown.

Check the FAQ instructions on how to download and install a Bitnami Stack for more details.

The application will be installed to the following default directories:

Operating System Directory
Windows C:\Bitnami\APPNAME-VERSION
Mac OS X /Applications/APPNAME-VERSION
Linux /opt/APPNAME-VERSION (running as root user)
OS X VM
  • Download the OS X VM file for the Bitnami Discourse Stack from the Bitnami website.
  • Begin the installation process by double-clicking the image file and dragging the WordPress OS X VM icon to the Applications folder.
  • Launch the VM by double-clicking the icon in the Applications folder.

What credentials do I need?

You need application credentials, consisting of a username and password. These credentials allow you to log in to your new Bitnami application.

What is the administrator username set for me to log in to the application for the first time?

  • For Windows, Linux and OS X installers, the username was configured by you when you first installed the application.
  • For OS X VMs, the username can be obtained by clicking the Bitnami badge at the bottom right corner of the application welcome page.

What is the administrator password?

  • For Windows, Linux and OS X installers, the password was configured by you when you first installed the application.
  • For OS X VMs, the password can be obtained by clicking the Bitnami badge at the bottom right corner of the application welcome page.

How to start or stop the services?

Linux

Bitnami native installers include a graphical tool to manage services. This tool is named manager-linux-x64.run on Linux and is located in the installation directory. To use this tool, double-click the file and then use the graphical interface to start, stop or restart services. Server log messages can be checked in the "Server Events" tab.

Management tool

The native installer also includes a command-line script to start, stop and restart applications, named ctlscript.sh. This script can be found in the installation directory and accepts the options start, stop, restart, and status. To use it, log in to the server console and execute it following the examples below:

  • Call it without any service names to start all services:

      $ sudo installdir/ctlscript.sh start
    
  • Use it to restart a specific service only by passing the service name as argument - for example, mysql, postgresql or apache:

      $ sudo installdir/ctlscript.sh restart mysql
      $ sudo installdir/ctlscript.sh restart postgresql
      $ sudo installdir/ctlscript.sh restart apache
    
  • Obtain current status of all services:

      $ installdir/ctlscript.sh status
    

The list of available services varies depending on the required components for each application.

Mac OS X

Bitnami native installers include a graphical tool to manage services. This tool is named manager-osx on Mac OS X and is located in the installation directory. To use this tool, double-click the file and then use the graphical interface to start, stop or restart services. Server log messages can be checked in the "Server Events" tab.

Management tool

The native installer also includes a command-line script to start, stop and restart applications, named ctlscript.sh. This script can be found in the installation directory and accepts the options start, stop, restart, and status. To use it, log in to the server console and execute it following the examples below:

  • Call it without any service names to start all services:

    $ sudo installdir/ctlscript.sh start
    
  • Use it to restart a specific service only by passing the service name as argument - for example, mysql or apache:

     $ sudo installdir/ctlscript.sh restart mysql
     $ sudo installdir/ctlscript.sh restart apache
    
  • Obtain current status of all services:

     $ installdir/ctlscript.sh status
    

The list of available services varies depending on the required components for each application.

NOTE: If you are using the stack manager for Mac OS X-VM, please check the following blog post to learn how to manage services from its graphical tool.

Windows

Bitnami native installers include a graphical tool to manage services. This tool is named manager-windows.exe on Windows and is located in the installation directory. To use this tool, double-click the file and then use the graphical interface to start, stop or restart services. Server log messages can be checked in the "Server Events" tab.

Management tool

The Windows native installer creates shortcuts to start and stop services created in the Start Menu, under "Programs -> Bitnami APPNAME Stack -> Bitnami Service". Servers can also be managed from the Windows "Services" control panel. Services are named using the format APPNAMESERVICENAME, where APPNAME is a placeholder for the application name and SERVICENAME is a placeholder for the service name. For example, the native installer for the Bitnami WordPress Stack installs services named wordpressApache and wordpressMySQL.

These services will be automatically started during boot. To modify this behaviour, refer to the section on disabling services on Windows.

How to configure outbound email settings?

To configure SMTP settings using an external SMTP server, you have to add the lines indicated below to the installdir/apps/discourse/htdocs/config/discourse.conf:

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

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.

An example for Gmail is as follows. Replace USERNAME and PASSWORD with your Gmail account username and password respectively.

smtp_address = "smtp.gmail.com"
smtp_port = 587
smtp_domain = example.com
smtp_user_name = 'USERNAME@gmail.com'
smtp_password = 'PASSWORD'
smtp_enable_start_tls = true
authentication = plain

To configure the application to use other third-party SMTP services for outgoing email, such as SendGrid or Mandrill, refer to the FAQ.

NOTE: If you are using Gmail as the outbound email server and have experienced issues trying to send emails correctly, check the How to troubleshoot Gmail SMTP issues to learn the causes of these issues and how to solve them.

How to install a plugin on Discourse?

You might want to extend the functionality of Discourse by installing a plugin. If you want to do this, you must get the repository URL for the plugin (where PLUGIN_REPO_URL is the URL to the repository of the plugin you want to install, like: https://github.com/discourse/discourse-akismet):

You will have to execute the following commands:

$ cd installdir/apps/discourse/htdocs
$ RAILS_ENV=production bundle exec rake plugin:install repo=PLUGIN_REPO_URL
$ RAILS_ENV=production bundle exec rake assets:precompile

How to remove a plugin on Discourse?

To remove a Discourse plugin, follow these steps:

  • Log in to the server console.
  • Navigate to the Discourse plugins directory:

      $ cd installdir/apps/discourse/htdocs/plugins
    
  • Execute the following commands, replacing PLUGIN-DIR with the name of the directory containing the plugin you wish to remove:

      $ rm -rf PLUGIN-DIR
      $ RAILS_ENV=production bundle exec rake assets:precompile
    

How to create a full backup of Discourse?

The Bitnami Discourse Stack is self-contained and the simplest option for performing a backup is to copy or compress the Bitnami stack installation directory. To do so in a safe manner, you will need to stop all servers, so this method may not be appropriate if you have people accessing the application continuously.

NOTE: If you want to create only a database backup, refer to these instructions for MySQL and PostgreSQL.

Backup on Linux and Mac OS X

Follow these steps:

  • Change to the directory in which you wish to save your backup.

     $ cd /your/directory
    
  • Stop all servers.

     $ sudo installdir/ctlscript.sh stop
    
  • Create a compressed file with the stack contents.

     $ sudo tar -pczvf application-backup.tar.gz installdir
    
  • Start all servers.

     $ sudo installdir/ctlscript.sh start
    
  • Download or transfer the application-backup.tar.gz file to a safe location.

You should now download or transfer the application-backup.tar.gz file to a safe location.

Backup on Windows

Follow these steps:

  • Stop all servers using the shortcuts in the Start Menu or the graphical manager tool.

  • Create a compressed file with the stack contents. You can use a graphical tool like 7-Zip or WinZip or just right-click the folder, click "Send to", and select the "Compressed (zipped) folder" option.

  • Download or transfer the compressed file to a safe location.

  • Start all servers using the shortcuts in the Start Menu or the graphical manager tool.

Restore on Linux and Mac OS X

Follow these steps:

  • Change to the directory containing your backup:

    $ cd /your/directory
    
  • Stop all servers.

    $ sudo installdir/ctlscript.sh stop
    
  • Move the current stack to a different location:

    $ sudo mv installdir /tmp/bitnami-backup
    
  • Uncompress the backup file to the original directory:

    $ sudo tar -pxzvf application-backup.tar.gz -C /
    
  • Start all servers.

    $ sudo installdir/ctlscript.sh start
    
IMPORTANT: When restoring, remember to maintain the original permissions for the files and folders. For example, if you originally installed the stack as the root user on Linux, make sure that the restored files are owned by root as well.

Restore on Windows

  • Change to the directory containing your backup:

       $ cd /your/directory
    
  • Stop all servers using the shortcuts in the Start Menu or the graphical manager tool.

  • Uninstall the previous services by executing the following command:

        $ serviceinstall.bat
    
  • Create a safe folder named Backups in the desktop and move the current stack to it. Remember to replace PATH with the right location of your folder:

        $ move installdir \PATH\Backups
    
  • Uncompress the backup file using a tool like 7-Zip or Winzip or just double-click the .zip file to uncompress it, and move it to the original directory.
  • Install services by running the following commands from an elevated command prompt:

      $ cd installdir
      $ serviceinstall.bat INSTALL
    
  • Start all servers using the shortcuts in the Start Menu or the graphical manager tool.

How to upgrade Discourse?

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

Migrating the database

Follow the steps below to migrate the database from an old version to a new one:

  • Create a database backup of the running application with the following command:

     $ pg_dump -U postgres bitnami_discourse > backup.sql 
    
  • Create a tarball with the uploaded files of the running application:

     $ tar -czvf uploads.tar.gz installdir/apps/discourse/htdocs/public/uploads
    
  • Copy both backups to the server hosting the new version.

  • On the new server, stop all servers and start only PostgreSQL:

     $ sudo installdir/ctlscript.sh stop
     $ sudo installdir/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 installdir/ctlscript.sh start redis 
     $ cd installdir/apps/discourse/htdocs 
     $ bin/rake db:migrate RAILS_ENV=production
    
  • Restore the uploaded files in the new server:

     $ tar -xzvf uploads.tar.gz -C /
    
  • Restart all servers:

     $ sudo installdir/ctlscript.sh start
    

Keeping in sync with the Discourse repository at GitHub

IMPORTANT: This procedure is supported since the Bitnami Discourse Stack v0.8.5-0.
NOTE: 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 and the standard process to upgrade the whole stack can be followed.

Since Discourse changes very fast, the Bitnami Discourse Stack includes the .git files necessary to stay in sync with the repository.

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. Follow these steps:

  • For Linux native installers, install the libc6-dev libraries. On Debian-based systems like Ubuntu, this is included in the build-essential package.

  • Change to the Discourse application directory:

     $ cd installdir/apps/discourse/htdocs
    
  • Stop the Apache and Discourse services:

     $ sudo installdir/ctlscript.sh stop apache
     $ sudo installdir/ctlscript.sh stop discourse_sidekiq
    
  • Stop and disable the Clockwork service if your current Discourse version uses it. This step is not required since v0.9.6.1.

     $ sudo installdir/ctlscript.sh stop discourse_clockwork
     $ sudo mv installdir/apps/discourse/scripts/clockwork.sh installdir/apps/discourse/scripts/clockwork.sh.disabled
    
  • Edit the file installdir/scripts/setenv.sh and comment the line:

     . installdir/scripts/build-setenv.sh
    
  • Edit the file installdir/ruby/.bundler/config and comment the line:

     BUNDLE_BUILD__NOKOGIRI: --with-iconv-dir=installdir/common
    
  • Change to the Discourse application directory:

     $ cd installdir/apps/discourse/htdocs
    
  • Checkout the master branch and pull the latest version. You will need to checkout the Gemfile and Gemfile.lock files to overwrite Bitnami's changes to support offline installations. Note that you will need to configure Git as described in the Troubleshooting section to stash the changes if this is the first time you're using it.

     $ git checkout Gemfile*
     $ git checkout bin
     $ git stash
     $ git checkout master
     $ git pull
     $ git checkout tags/vLATEST_VERSION
     $ git stash apply
    
NOTE: You may need to remove raindrops, unicorn and kgio gems from the Gemfile.lock file.
  • Execute the following command:

      $ sudo bundle install --without development test sqlite --binstubs --deployment
    
  • Apply any new database migrations:

     $ sudo installdir/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 installdir/ruby/bin/ruby bin/rake assets:precompile RAILS_ENV=production
    
  • Remove the Discourse cache:

     $ sudo rm -rf tmp/cache
    
  • Restart Apache and Discourse servers:

     $ sudo installdir/ctlscript.sh start
    

Troubleshooting

  • If you run git and you get this output:

     Please tell me who you are.
    

    Run the commands below, replacing the placeholders with your name and email address:

     $ git config --global user.email "you@example.com"
     $ git config --global user.name "Your Name"  
    
  • If you see the following error:

     rake aborted!
     cannot load such file -- rb-inotify
    

Check that you are running the command using the rake command in the Discourse directory and that the command is running in production mode:

    $ export RAILS_ENV=production
    $ cd installdir/apps/discourse/htdocs
    $ bin/rake bundle install
  • If there is a merge conflict, it should be fixed manually. You will see an error like this:

     $ 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
    

    To resolve this, the files listed must be edited. There are two options:

    • Keep local changes. For each conflicting file:

      • Remove everything from <<<<<<< Updated upstream to ======= and the line >>>>>>> Stashed changes. Then, run the following command:

            $ git add FILENAME
        
      • Check everything. Output of this command should be as shown:

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

            $ git reset HEAD
        
    • Discard local changes. For each conflicting file:

      • Remove everything from ======= to >>>>>>> Stashed changes and the line <<<<<<< Updated upstream. Then, run the following command:

            $ git add FILENAME
        
      • Check everything. Output of this command should be as shown:

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

            $ git reset HEAD
        
  • On Linux 32-bit instances, you may have problems with the gem libv8-3.16.14.3.gem because there is no precompiled version of this gem for this platform. An easy workaround would be to edit the Gemfile.lock file and replacing libv8 (3.16.14.3) with libv8 (3.16.14.1).

How to create an SSL certificate?

OpenSSL is required to create an SSL certificate. A certificate request can then be sent to a certificate authority (CA) to get it signed into a certificate, or if you have your own certificate authority, you may sign it yourself, or you can use a self-signed certificate (because you just want a test certificate or because you are setting up your own CA).

Follow the steps below for your platform.

Linux and Mac OS X

NOTE: OpenSSL will typically already be installed on Linux and Mac OS X. If not installed, install it manually using your operating system's package manager.

Follow the steps below:

  • Generate a new private key:

     $ sudo openssl genrsa -out installdir/apache2/conf/server.key 2048
    
  • Create a certificate:

     $ sudo openssl req -new -key installdir/apache2/conf/server.key -out installdir/apache2/conf/cert.csr
    
    IMPORTANT: Enter the server domain name when the above command asks for the "Common Name".
  • Send cert.csr to the certificate authority. When the certificate authority completes their checks (and probably received payment from you), they will hand over your new certificate to you.

  • Until the certificate is received, create a temporary self-signed certificate:

     $ sudo openssl x509 -in installdir/apache2/conf/cert.csr -out installdir/apache2/conf/server.crt -req -signkey installdir/apache2/conf/server.key -days 365
    
  • Back up your private key in a safe location after generating a password-protected version as follows:

     $ sudo openssl rsa -des3 -in installdir/apache2/conf/server.key -out privkey.pem
    

    Note that if you use this encrypted key in the Apache configuration file, it will be necessary to enter the password manually every time Apache starts. Regenerate the key without password protection from this file as follows:

     $ sudo openssl rsa -in privkey.pem -out installdir/apache2/conf/server.key
    

Windows

NOTE: OpenSSL is not typically installed on Windows. Before following the steps below, download and install a binary distribution of OpenSSL.

Follow the steps below once OpenSSL is installed:

  • Set the OPENSSL_CONF environment variable to the location of your OpenSSL configuration file. Typically, this file is located in the bin/ subdirectory of your OpenSSL installation directory. Replace the OPENSSL-DIRECTORY placeholder in the command below with the correct location.

     $ set OPENSSL_CONF=C:\OPENSSL-DIRECTORY\bin\openssl.cfg
    
  • Change to the bin/ sub-directory of the OpenSSL installation directory. Replace the OPENSSL-DIRECTORY placeholder in the command below with the correct location.

     $ cd C:\OPENSSL-DIRECTORY\bin
    
  • Generate a new private key:

     $ openssl genrsa -out installdir/apache2/conf/server.key 2048
    
  • Create a certificate:

     $ openssl req -new -key installdir/apache2/conf/server.key -out installdir/apache2/conf/cert.csr
    
    IMPORTANT: Enter the server domain name when the above command asks for the "Common Name".
  • Send cert.csr to the certificate authority. When the certificate authority completes their checks (and probably received payment from you), they will hand over your new certificate to you.

  • Until the certificate is received, create a temporary self-signed certificate:

     $ openssl x509 -in installdir/apache2/conf/cert.csr -out installdir/apache2/conf/server.crt -req -signkey installdir/apache2/conf/server.key -days 365
    
  • Back up your private key in a safe location after generating a password-protected version as follows:

     $ openssl rsa -des3 -in installdir/apache2/conf/server.key -out privkey.pem
    

    Note that if you use this encrypted key in the Apache configuration file, it will be necessary to enter the password manually every time Apache starts. Regenerate the key without password protection from this file as follows:

     $ openssl rsa -in privkey.pem -out installdir/apache2/conf/server.key
    

Find more information about certificates at http://www.openssl.org.

How to enable HTTPS support with SSL certificates?

TIP: If you wish to use a Let's Encrypt certificate, you will find specific instructions for enabling HTTPS support with Let's Encrypt SSL certificates in our Let's Encrypt guide.
NOTE: The steps below assume that you are using a custom domain name and that you have already configured the custom domain name to point to your cloud server.

Bitnami images come with SSL support already pre-configured and with a dummy certificate in place. Although this dummy certificate is fine for testing and development purposes, you will usually want to use a valid SSL certificate for production use. You can either generate this on your own (explained here) or you can purchase one from a commercial certificate authority.

Once you obtain the certificate and certificate key files, you will need to update your server to use them. Follow these steps to activate SSL support:

  • Use the table below to identify the correct locations for your certificate and configuration files.

    Variable Value
    Current application URL https://[custom-domain]/
      Example: https://my-domain.com/ or https://my-domain.com/appname
    Apache configuration file installdir/apache2/conf/bitnami/bitnami.conf
    Certificate file installdir/apache2/conf/server.crt
    Certificate key file installdir/apache2/conf/server.key
    CA certificate bundle file (if present) installdir/apache2/conf/server-ca.crt
  • Copy your SSL certificate and certificate key file to the specified locations.

    NOTE: If you use different names for your certificate and key files, you should reconfigure the SSLCertificateFile and SSLCertificateKeyFile directives in the corresponding Apache configuration file to reflect the correct file names.
  • If your certificate authority has also provided you with a PEM-encoded Certificate Authority (CA) bundle, you must copy it to the correct location in the previous table. Then, modify the Apache configuration file to include the following line below the SSLCertificateKeyFile directive. Choose the correct directive based on your scenario and Apache version:

    Variable Value
    Apache configuration file installdir/apache2/conf/bitnami/bitnami.conf
    Directive to include (Apache v2.4.8+) SSLCACertificateFile "installdir/apache2/conf/server-ca.crt"
    Directive to include (Apache < v2.4.8) SSLCertificateChainFile "installdir/apache2/conf/server-ca.crt"
    NOTE: If you use a different name for your CA certificate bundle, you should reconfigure the SSLCertificateChainFile or SSLCACertificateFile directives in the corresponding Apache configuration file to reflect the correct file name.
  • Once you have copied all the server certificate files, you may make them readable by the root user only with the following commands:

     $ sudo chown root:root installdir/apache2/conf/server*
    
     $ sudo chmod 600 installdir/apache2/conf/server*
    
  • Open port 443 in the server firewall. Refer to the FAQ for more information.

  • Restart the Apache server.

You should now be able to access your application using an HTTPS URL.

How to force HTTPS redirection with Apache?

Add the following lines in the default Apache virtual host configuration file at installdir/apache2/conf/bitnami/bitnami.conf, inside the default VirtualHost directive, so that it looks like this:

<VirtualHost _default_:80>
  DocumentRoot "installdir/apache2/htdocs"
  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
  ...
</VirtualHost>

After modifying the Apache configuration files:

  • Open port 443 in the server firewall. Refer to the FAQ for more information.

  • Restart Apache to apply the changes.

How to debug Apache errors?

Once Apache starts, it will create two log files at installdir/apache2/logs/access_log and installdir/apache2/logs/error_log respectively.

  • The access_log file is used to track client requests. When a client requests a document from the server, Apache records several parameters associated with the request in this file, such as: the IP address of the client, the document requested, the HTTP status code, and the current time.

  • The error_log file is used to record important events. This file includes error messages, startup messages, and any other significant events in the life cycle of the server. This is the first place to look when you run into a problem when using Apache.

If no error is found, you will see a message similar to:

Syntax OK

Updating the IP address or hostname

Discourse requires updating the IP address/domain name if the machine IP address/domain name changes. The bnconfig tool also has an option which updates the IP address, called --machine_hostname (use --help to check if that option is available for your application). Note that this tool changes the URL to http://NEW_DOMAIN/discourse.

$ sudo installdir/apps/discourse/bnconfig --machine_hostname NEW_DOMAIN

If you have configured your machine to use a static domain name or IP address, you should rename or remove the installdir/apps/discourse/bnconfig file.

$ sudo mv installdir/apps/discourse/bnconfig installdir/apps/discourse/bnconfig.disabled
NOTE: Be sure that your domain is propagated. Otherwise, this will not work. You can verify the new DNS record by using the Global DNS Propagation Checker and entering your domain name into the search field.

You can also change your hostname by modifying it in your hosts file. Enter the new hostname using your preferred editor.

$ sudo nano /etc/hosts
  • Add a new line with the IP address and the new hostname. Here's an example. Remember to replace the IP-ADDRESS and DOMAIN placeholders with the correct IP address and domain name.

    IP-ADDRESS DOMAIN

How to find the database credentials?

  • Database username: postgres.
  • Database password: The password entered during the installation process.

How to connect to the PostgreSQL database?

You can connect to the PostgreSQL database from the same computer where it is installed with the psql client tool.

$ psql -U postgres

You will be prompted to enter the *postgres* user password. This is the same as the [application password](/installer/faq#how-to-find-application-credentials).

How to access phpPgAdmin?

You should be able to access phpPgAdmin directly, by browsing to http://127.0.0.1:8080/phppgadmin (Linux or Mac OS X) or http://127.0.0.1/phppgadmin (Windows).

The username is postgres for phpPgAdmin, and the password is the one specified by you during the installation process.

How to modify PHP settings for Apache?

The PHP configuration file allows you to configure the modules enabled, the email settings or the size of the upload files. It is located at installdir/php/etc/php.ini.

For example, to modify the default upload limit for PHP, update the PHP configuration file following these instructions.

After modifying the PHP configuration file, restart both Apache and PHP-FPM for the changes to take effect:

$ sudo installdir/ctlscript.sh restart apache
$ sudo installdir/ctlscript.sh restart php-fpm

How to modify the allowed limit for uploaded files in Apache?

Modify the following options in the installdir/php/etc/php.ini file to increase the allowed size for uploads:

; Maximum size of POST data that PHP will accept.
post_max_size = 16M

; Maximum allowed size for uploaded files.
upload_max_filesize = 16M

Restart PHP-FPM and Apache for the changes to take effect.

$ sudo installdir/ctlscript.sh restart apache
$ sudo installdir/ctlscript.sh restart php-fpm    

How to create a backup of Discourse using the admin interface?

Backup

To backup, follow the steps below:

  • Log in to the application as an administrator.
  • Select the "Admin -> Backups" menu item.
  • Click the "Backup" button.

    Discourse backup

It is possible to create a backup with or without uploaded images. Note this process could take some time depending on your database and the size of the uploaded files.

Once the backup has been created, download the backup file and store it in a safe location.

Restore

Restoring a backup in Discourse is disabled by default. To restore, follow the steps below:

  • Log in to the application as an administrator.
  • Enable restoration using the "Settings -> Backups -> Allow restore" menu.

    Discourse restore

  • Select the "Admin -> Backups" menu item.
  • Upload the backup file and restore its contents.
IMPORTANT: Discourse requires you to manually the postgres user's password, by editing the installdir/postgresql/bin/setenv.sh file and adding the line below:
export PGPASSWORD="POSTGRES_USER_PASSWORD"

How to change the default administrator email?

During the deployment of Discourse, the administrator email used by default is user@example.com. As the administrator user, you most likely want to change it to your personal email address.

Changing the default administrator email requires an email verification from the current user@example.com email address, which is not possible from the Discourse settings panel. To do so, you need to perform some queries in the PostgreSQL database.

Follow the steps below in order to change the default administrator email in Discourse:

  • Log in to the server console. Refer to our FAQs to learn how to connect to the server through SSH.
  • Run the commands below:

      $ cd installdir/apps/discourse/htdocs/
      $ sudo RAILS_ENV=production bundle exec rails c
    

    A new prompt should appear, as shown below:

      irb(main):001:0>
    
  • At the prompt, run the following commands to change the email address of the default user account to a new email address. Replace the EMAIL_ADDRESS placeholder in the commands below with your desired email address:

      u = User.find_by_username("user")
      u.email = "YOUR_NEW_EMAIL_ADDRESS"
      u.email_tokens.create(email: u.email)
      u.activate
      u.save!
    

The default administrator email address will be changed. You can verify the changes in your application admin panel:

  • In the top right menu, click the "Hamburger" button and select the "Admin" option.

    Discourse admin panel

  • Navigate to the "Users" section. You can check that the email associated with the admin user has changed:

    Discourse default admin email changed

How to enable multisite support?

Follow these steps to enable multisite support:

  • Create a new database and database user for the new site. Execute the following commands at the server console, remembering to replace the DATABASE_NAME, DATABASE_USER and DATABASE_PASSWORD placeholders with actual values.

     $ installdir/postgresql/bin/psql -U postgres -c "CREATE DATABASE DATABASE_NAME;"
     $ installdir/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"
     $ installdir/postgresql/bin/psql -U postgres -c "ALTER DATABASE DATABASE_NAME OWNER TO DATABASE_USER;"
     $ installdir/postgresql/bin/psql -U postgres -d database_name -c "CREATE EXTENSION HSTORE; CREATE EXTENSION pg_trgm;"
    
  • Copy the config/multisite.yml.production-sample file:

     $ sudo cp installdir/apps/discourse/htdocs/config/multisite.yml.production-sample installdir/apps/discourse/htdocs/config/multisite.yml
    
  • Edit the file to use the database created previously. Replace the DATABASE_NAME, DATABASE_USER and DATABASE_PASSWORD placeholders with actual values, and the HOSTNAME placeholder with the host name for the new site.

     database_name:
       adapter: postgresql
       database: DATABASE_NAME
       username: DATABASE_USER
       password: "DATABASE_PASSWORD"
       host: installdir/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:
         - HOSTNAME
    
  • For testing purposes, add the new hostname to the /etc/hosts file, as below:

     IP_ADDRESS HOSTNAME
    
  • Migrate the database

     $ cd installdir/apps/discourse/htdocs
     $ bin/bundle exec bin/rake multisite:migrate RAILS_ENV='production'
    
  • Create an administrative user:

     $ bin/rake admin:create RAILS_ENV='production' RAILS_DB=DATABASE_NAME
    

You should now be able to access your new site using the new domain name.

How to enable SSL in Discourse?

First, configure Apache to enable SSL connections. Then, force HTTPS for all Discourse links using one of the following options:

  • Enable the following option in the Discourse config file at installdir/apps/discourse/htdocs/config/site_settings.yml:

    security:
       enable_flash_video_onebox: false
       use_https: true
    
NOTE: In Discourse versions prior to v0.9.8.1, the option name is use_ssl instead of use_https.
  • Update the HTTPS port entry in the database by following the steps below:

    • Log in to the server console.

    • Start the MySQL command-line client and connect to the MySQL database.

    • Execute the following SQL command, replacing the NEW_PORT placeholder with the number of the SSL port. If the SSL port is 443, leave the NEW_PORT placeholder empty.

        mysql> UPDATE site_settings SET value = 'NEW_PORT' WHERE name = 'port'
      
  • Disable HTTP and redirect all requests to HTTPS URLs.

  • Restart the server:

     $ sudo installdir/ctlscript.sh restart
    

How to use a CDN?

If using a CDN, users could experience problems with Discourse icons under Firefox. To fix this error, uncomment these lines in the installdir/apps/discourse/conf/httpd-app.conf file:

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

How to change to development mode?

Follow these steps:

  • Copy the production database settings to the development section of the config/database.yml file. If you prefer, you can also populate a new database.

  • Stop the Apache server:

     $ sudo installdir/ctlscript.sh stop apache
    
  • Checkout the latest Gemfile and Gemfile.lock files and install the required gems:

     $ cd installdir/apps/discourse/htdocs
     $ git checkout Gemfile*
     $ sudo bundle install --without test sqlite
    
  • Clean assets

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

     $ sudo rails server -p 80
    

The Sidekiq and Clockwork servers run in production mode by default. Change the mode in the Clockwork script at installdir/apps/discourse/scripts/clockwork.sh, as shown below:

CLOCKWORK_START="installdir/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"

Similarly, change the mode in the Sidekiq script at installdir/apps/discourse/scripts/sidekiq.sh:

SIDEKIQ_START="installdir/ruby/bin/ruby $DISCOURSE_HOME/bin/sidekiq -P $SIDEKIQ_PIDFILE -e production -L 
nativeInstaller

Bitnami Documentation