Guide is working, but it's missing details on how to install pg_trgm extension. https://github.com/fire/pkgsrc-wip/tree/pg_trgm
- 2 GB of RAM
- 2 GB of swap
- 2 processor cores
With 2 GB of memory and dual cores, you can run two instances of the thin server (NUM_WEBS=2
), and easily host anything but the largest of forums.
1 GB of memory, 3 GB of swap and a single core CPU are the minimums for a steady state, running Discourse forum – but it's simpler to just throw a bit more hardware at the problem if you can, particularly during the install.
sudo apt-get -y install build-essential libssl-dev libyaml-dev git libtool libxslt-dev libxml2-dev libpq-dev gawk curl pngcrush imagemagick python-software-properties
pkgin in build-essential git gawk curl pngcrush ImageMagick libtool libxslt libxml2 gawk curl
pkgin in redis
/usr/sbin/svcadm enable svc:/pkgsrc/redis:default
pkgin in ruby-2.1.1 ruby211-nokogiri ruby211-xslt ruby211-bundler ruby211-readline
groupadd discourse
useradd \
-s /bin/false \
-c 'Discourse forum' \
-g discourse \
-d /home/discourse -m discourse
sudo pkgin postgres-93 postgresql93-datatypes
# TODO install pg_trgm extension
# You have to compile the package from https://github.com/fire/pkgsrc-wip/tree/pg_trgm/postgresql93-trgm
sudo -u postgres createuser -s discourse
# If you will be using password authentication on your database, only
# necessary if the database will be on a remote host
sudo -u postgres psql -c "alter user discourse password 'todayisagooddaytovi';" # Note choose your own password
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE discourse to discourse";
sudo -u postgres /opt/loca/bin/nano /var/pgsql/data/pg_hba.conf
# Add "local discourse discourse peer"
# before "local all all password"
sudo svcadm restart postgresql
Pull down the latest code.
Now would be a great time to consider forking, if want to work from your own copy of discourse.
If you don't need to customize your installation, and want less hassle upgrading clone from Discourse's repo.
sudo -u discourse /bin/bash
git clone git://github.com/discourse/discourse.git tmp && mv tmp/.git . && rm -rf tmp && git reset --hard
git checkout latest-release
# Change Gemfile and Gemfile.lock to use tzinfo-data # May 31, 2014
bundle install --path vendor/bundle
bundle install --without test --deployment
# Run these commands as the discourse user
cd /home/discourse/config
cp discourse_quickstart.conf discourse.conf
chmod 600 discourse.conf
Database/Hostname:
- change database username/password if appropriate
- change hostname to the name you'll use to access the Discourse site, e.g. "forum.example.com"
- no changes if this is the only application using redis, but have a look
- browse through all the settings and be sure to add your mail server SMTP settings so outgoing mail can be sent (we recommend Mandrill)
- If your users will come from "internal" private unroutable IPs like 10.x.x.x or 192.168.x.x please see this topic.
# Run these commands as the discourse user
# The database name here should match the production one in database.yml
cd /home/discourse
createdb discourse
RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production bundle exec rake db:migrate
RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production bundle exec rake assets:precompile
cd /home/discourse
RAILS_ENV=production bundle exec rails c
SiteSetting.default_locale = 'fr'
LocaleSiteSetting.values
=> ["cs", "da", "de", "en", "es", "fr", "id", "it", "nb_NO", "nl", "pt", "ru", "sv", "zh_CN", "zh_TW"]
pkgin in nginx -y
Copy the nginx config:
mkdir -p /opt/local/etc/nginx/sites-enabled
mkdir -p /opt/local/etc/nginx/sites-available
cp /home/discourse/config/nginx.sample.conf /etc/nginx/sites-available/discourse.conf
ln -s /opt/local/etc/nginx/sites-available/discourse.conf nginx/sites-enabled/
Edit nginx.conf and add the include line after http {
vim /opt/local/etc/nginx/nginx.conf
#add this line after http {
include /opt/local/etc/nginx/sites-enabled/*.conf;
Enable nginx:
svcadm enable nginx
Look at /home/discourse/config/nginx.global.conf
Look at /home/discourse/config/nginx.sample.conf
Change the paths in nginx.sample.conf and change the name of the config to subdomain.example.com
.
Figure out how to disable default site
Edit /etc/local/nginx/sites-enabled/discourse.conf
- edit
server_name
. Example:server_name cain.discourse.org test.cain.discourse.org;
- change socket count depending on your NUM_WEB count
- change socket paths if Discourse is installed to a different location
- modify root location if Discourse is installed to a different location
Reload nginx by running
svcadm enable nginx
su
nano rails-discourse.xml # Copy bottom smf configuration
svccfg import rails-discourse.xml
svcadm enable rails-discourse
tail -f -n 50 /var/svc/log/site-rails-discourse:default.log
sudo su - discourse
gem install unicorn --user-install
# Add gem directory to path
# Disabled for now - log rotation isn't *quite* complete
#0 0 * * * /usr/sbin/logrotate /var/www/discourse/config/logrotate.conf
IMPORTANT: Discourse relies heavily on email. If your email configuration is not correct, you will effectively have a broken forum. Please, head over to our Mail Setup Guide to find out more information on how to properly setup emails.
Congratulations! You've got Discourse installed and running!
Now make yourself an administrator account. Browse to your Discourse instance and create an account by logging in normally, then run the commands:
# Run these commands as the discourse user
sudo -u discourse /bin/bash && cd ~
RAILS_ENV=production bundle exec rails c
# Administratorize yourself:
# (in rails console)
> me = User.find_by_username_or_email('[email protected]')
> me.activate # use this in case you haven't configured your mail server and therefore can't receive the activation mail.
> me.admin = true
> me.save
# Mark yourself as the 'system user':
# (in rails console)
> SiteSetting.site_contact_username = me.username
Custom assets such as images should be placed somewhere under:
/home/discourse/public/
For example, create a local
directory and place it into:
/home/discourse/public/uploads/local/michael.png
The corresponding site setting is:
logo_small_url: /uploads/local/michael.png
sudo svcadm disable rails-discourse
# Back up your install
sudo -u discourse /bin/bash
DATESTAMP=$(TZ=UTC date +%F-%T)
pg_dump --no-owner --clean discourse | gzip -c > ~/discourse-db-$DATESTAMP.sql.gz
tar cfz ~/discourse-dir-$DATESTAMP.tar.gz -C /home/discourse
# get the latest Discourse code
cd /home/discourse
git checkout master
git pull
git fetch --tags
# To run on the latest numbered release instead of bleeding-edge:
#git checkout latest-release
#
# Follow the section below titled:
# "Check sample configuration files for new settings"
bundle install --without test --deployment
RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production bundle exec rake db:migrate
RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production bundle exec rake assets:precompile
sudo svcadm enable rails-discourse
Check the sample configuration files provided in the repo with the ones being used for additional recommended settings and merge those in:
# Run these commands as the discourse user
cd /home/discourse
diff -u config/discourse_quickstart.conf config/discourse.conf
$ diff -u config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf
--- config/nginx.sample.conf 2013-07-15 17:38:06.521507000 +0000
+++ /etc/nginx/conf.d/discourse.conf 2013-07-15 17:52:46.649507024 +0000
@@ -12,17 +12,18 @@
gzip_min_length 1000;
gzip_types application/json text/css application/x-javascript;
- server_name enter.your.web.hostname.here;
+ server_name webtier.discourse.org;
sendfile on;
keepalive_timeout 65;
- client_max_body_size 2m;
location / {
root /home/discourse/discourse/public;
This change reflects a change in placeholder information plus (importantly)
adding the client_max_body_size 2m;
directive to the nginx configuration.
This change should also be made to your production file.
No need to manually compile
pg_trgm
. That extension is in thepostgresql93-contrib
package of pkgsrc.