PageRenderTime 44ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/docs/INSTALL-ubuntu.md

https://gitlab.com/suyesh/discourse
Markdown | 401 lines | 273 code | 128 blank | 0 comment | 0 complexity | 8725c4f94111e151c181f0994dd03856 MD5 | raw file
  1. # Warning: This Guide is Deprecated
  2. We only support Docker based installs now. Please see [our **official install guide**](https://github.com/discourse/discourse/blob/master/docs/INSTALL.md) for supported install instructions.
  3. > # Discourse Ubuntu Install Guide
  4. > ## Recommended Server Hardware
  5. > - 2 GB of RAM
  6. > - 2 GB of swap
  7. > - 2 processor cores
  8. > 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.
  9. > 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.
  10. > ## Install Ubuntu Server 12.04 LTS (or later) with the package groups:
  11. > Yes, you can in theory pick the distro of your choice, but to keep this guide sane, we're picking one, and it's Ubuntu. Feel free to substitute the distro of your choice, the steps are mostly the same.
  12. > ![screenshot of package group selection screen](https://raw.github.com/discourse/discourse-docimages/master/install/ubuntu%20-%20install%20-%20software%20selection.png)
  13. > * Basic Ubuntu server
  14. > * OpenSSH server
  15. > * Mail server
  16. > * PostgreSQL database (9.1+)
  17. > You may be working on an already-installed or automatically deployed system, in which case you can install them afterwards:
  18. > # Run these commands as your normal login (e.g. "michael")
  19. > sudo apt-get update && sudo apt-get -y upgrade
  20. > sudo apt-get install tasksel
  21. > sudo tasksel install openssh-server
  22. > sudo tasksel install mail-server
  23. > sudo tasksel install postgresql-server
  24. > If the above installation is stuck, please use the following method instead ([detail](https://bugs.launchpad.net/ubuntu/+source/debconf/+bug/141601)):
  25. > apt-get install postgresql-server^
  26. > ### Configure the mail server:
  27. > ![screenshot of mail server type configuration screen](https://raw.github.com/discourse/discourse-docimages/master/install/ubuntu%20-%20install%20-%20mail_1%20system%20type.png)
  28. > In our example setup, we're going to configure as a 'Satellite system', forwarding all mail to our egress servers for delivery. You'll probably want to do that unless you're handling mail on the same machine as the Discourse software.
  29. > ![screenshot of mail name configuration screen](https://raw.github.com/discourse/discourse-docimages/master/install/ubuntu%20-%20install%20-%20mail_2%20mailname.png)
  30. > You probably want to configure your 'mail name' to be the base name of your domain. Note that this does not affect any email sent out by Discourse itself, just unqualified mail generated by systems programs.
  31. > ![screenshot of relay host configuration screen](https://raw.github.com/discourse/discourse-docimages/master/install/ubuntu%20-%20install%20-%20mail_3%20relayconfig.png)
  32. > If you have a mail server responsible for handling the egress of email from your network, enter it here. Otherwise, leave it blank.
  33. > ## Additional system packages
  34. > Install necessary packages:
  35. > # Run these commands as your normal login (e.g. "michael")
  36. > 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
  37. > # If you're on Ubuntu >= 12.10, change:
  38. > # python-software-properties to software-properties-common
  39. > ## Caching: Redis
  40. > Redis is a networked, in memory key-value store cache. Without the Redis caching layer, we'd have to go to the database a lot more often for common information and the site would be slower as a result.
  41. > Be sure to install the latest stable Redis, as the package in the distro may be a bit old:
  42. > sudo apt-add-repository -y ppa:rwky/redis
  43. > sudo apt-get update
  44. > sudo apt-get install redis-server
  45. > ## Web Server: nginx
  46. > nginx is used for:
  47. > * reverse proxy (i.e. load balancer)
  48. > * static asset serving (since you don't want to do that from ruby)
  49. > * anonymous user cache
  50. > At Discourse, we recommend the latest version of nginx (we like the new and
  51. > shiny). To install on Ubuntu:
  52. > # Run these commands as your normal login (e.g. "michael")
  53. > # Remove any existing versions of nginx
  54. > sudo apt-get remove '^nginx.*$'
  55. > # Setup a sources.list.d file for the nginx repository
  56. > cat << 'EOF' | sudo tee /etc/apt/sources.list.d/nginx.list
  57. > deb http://nginx.org/packages/ubuntu/ precise nginx
  58. > deb-src http://nginx.org/packages/ubuntu/ precise nginx
  59. > EOF
  60. > # Add nginx key
  61. > curl http://nginx.org/keys/nginx_signing.key | sudo apt-key add -
  62. > # install nginx
  63. > sudo apt-get update && sudo apt-get -y install nginx
  64. > ## Install Ruby with RVM
  65. > ### RVM : Single-user installation
  66. > We recommend installing RVM isolated to a single user's environment.
  67. > ## Discourse setup
  68. > Create Discourse user:
  69. > # Run these commands as your normal login (e.g. "michael")
  70. > sudo adduser --shell /bin/bash --gecos 'Discourse application' discourse
  71. > sudo install -d -m 755 -o discourse -g discourse /var/www/discourse
  72. > Give Postgres database rights to the `discourse` user:
  73. > # Run these commands as your normal login (e.g. "michael")
  74. > sudo -u postgres createuser -s discourse
  75. > # If you will be using password authentication on your database, only
  76. > # necessary if the database will be on a remote host
  77. > sudo -u postgres psql -c "alter user discourse password 'todayisagooddaytovi';"
  78. > Change to the 'discourse' user:
  79. > # Run this command as your normal login (e.g. "michael"), further commands should be run as 'discourse'
  80. > sudo su - discourse
  81. > Install RVM
  82. > # As 'discourse'
  83. > # Install RVM
  84. > \curl -s -S -L https://get.rvm.io | bash -s stable
  85. > # Refresh your profile
  86. > . ~/.rvm/scripts/rvm
  87. > Install missing packages
  88. > # Install necessary packages for building ruby (this will only work if
  89. > # you've given discourse sudo permissions, which is *not* the default)
  90. > # rvm requirements
  91. > # NOTE: rvm will tell you which packages you (or your sysadmin) need
  92. > # to install during this step. As discourse does not have sudo
  93. > # permissions (likely the case), run:
  94. > rvm --autolibs=read-fail requirements
  95. > # For instance, if prompted with `libreadline6-dev libsqlite3-dev sqlite3 autoconf' etc
  96. > # Install the missing packages with this command, run as your user:
  97. > # sudo apt-get install libreadline6-dev libsqlite3-dev sqlite3 autoconf libgdbm-dev libncurses5-dev bison libffi-dev
  98. > # Repeat the autolibs test until you see "Requirements installation successful"
  99. > Build and install ruby
  100. > rvm install 2.0.0
  101. > # Use installed ruby as default
  102. > rvm use 2.0.0 --default
  103. > # Install bundler
  104. > gem install bundler
  105. > Continue with Discourse installation
  106. > # Pull down the latest code
  107. > # Now would be a great time to consider [forking](https://help.github.com/articles/fork-a-repo), if want to work from your own copy of discourse
  108. > #If you don't need to customize your installation, and want less hassle upgrading clone from Discourse's repo
  109. > git clone git://github.com/discourse/discourse.git /var/www/discourse
  110. > cd /var/www/discourse
  111. > # To run on the most recent numbered release instead of bleeding-edge:
  112. > #git checkout latest-release
  113. > # Install necessary gems
  114. > bundle install --deployment --without test
  115. > _If you have errors building the native extensions, ensure you have sufficient free system memory. 1GB with no swap isn't enough, we recommend having 2GB as a minimum._
  116. > Configure Discourse:
  117. > # Run these commands as the discourse user
  118. > cd /var/www/discourse/config
  119. > cp discourse_quickstart.conf discourse.conf
  120. > cp discourse.pill.sample discourse.pill
  121. > Editing /var/www/discourse/config/discourse.conf:
  122. > Database/Hostname:
  123. > - change database username/password if appropriate
  124. > - change `hostname` to the name you'll use to access the Discourse site, e.g. "forum.example.com"
  125. > Redis:
  126. > - no changes if this is the only application using redis, but have a look
  127. > E-mail:
  128. > - browse through all the settings and be sure to add your mail server SMTP settings so outgoing mail can be sent (we recommend [Mandrill](https://mandrillapp.com))
  129. > - If your users will come from "internal" [private unroutable IPs](https://en.wikipedia.org/wiki/Private_network) like 10.x.x.x or 192.168.x.x please [see this topic](http://meta.discourse.org/t/all-of-my-internal-users-show-as-coming-from-127-0-0-1/6607).
  130. > Editing: /var/www/discourse/config/discourse.pill
  131. > - change application name from 'discourse' if necessary
  132. > - Ensure appropriate Bluepill.application line is uncommented
  133. > Initialize the database:
  134. > # Run these commands as the discourse user
  135. > # The database name here should match the production one in database.yml
  136. > cd /var/www/discourse
  137. > createdb discourse_prod
  138. > RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production bundle exec rake db:migrate
  139. > RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production bundle exec rake assets:precompile
  140. > Not english? Set the default language as appropriate:
  141. > # Run these commands as the discourse user
  142. > cd /var/www/discourse
  143. > RAILS_ENV=production bundle exec rails c
  144. > SiteSetting.default_locale = 'fr'
  145. > # Not sure if your locale is supported? Check at the rails console:
  146. > LocaleSiteSetting.values
  147. > => ["cs", "da", "de", "en", "es", "fr", "id", "it", "nb_NO", "nl", "pt", "ru", "sv", "zh_CN", "zh_TW"]
  148. > ## nginx setup
  149. > # Run these commands as your normal login (e.g. "michael")
  150. > sudo cp /var/www/discourse/config/nginx.global.conf /etc/nginx/conf.d/local-server.conf
  151. > sudo cp /var/www/discourse/config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf
  152. > If Discourse will be the only site served by nginx, disable the nginx default
  153. > site:
  154. > - `sudo mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.disabled`
  155. > - Otherwise, only `server_name`s configured below in `discourse.conf` will be passed to Discourse.
  156. > Edit /etc/nginx/conf.d/discourse.conf
  157. > - edit `server_name`. Example: `server_name cain.discourse.org test.cain.discourse.org;`
  158. > - change socket count depending on your NUM_WEB count
  159. > - change socket paths if Discourse is installed to a different location
  160. > - modify root location if Discourse is installed to a different location
  161. > Reload nginx by running
  162. > # Run as your normal login (e.g. "michael")
  163. > sudo /etc/init.d/nginx reload
  164. > ## Bluepill setup
  165. > Configure Bluepill:
  166. > # Run these commands as the discourse user
  167. > gem install bluepill
  168. > echo 'alias bluepill="NOEXEC_DISABLE=1 bluepill --no-privileged -c ~/.bluepill"' >> ~/.bash_aliases
  169. > rvm wrapper $(rvm current) bootup bluepill
  170. > rvm wrapper $(rvm current) bootup bundle
  171. > Start Discourse:
  172. > # Run these commands as the discourse user
  173. > RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ROOT=/var/www/discourse RAILS_ENV=production NUM_WEBS=2 bluepill --no-privileged -c ~/.bluepill load /var/www/discourse/config/discourse.pill
  174. > Add the Bluepill startup to crontab.
  175. > # Run these commands as the discourse user
  176. > crontab -e
  177. > Add the following lines:
  178. > @reboot RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ROOT=/var/www/discourse RAILS_ENV=production NUM_WEBS=2 /home/discourse/.rvm/bin/bootup_bluepill --no-privileged -c ~/.bluepill load /var/www/discourse/config/discourse.pill
  179. > ## Log rotation setup
  180. > # Disabled for now - log rotation isn't *quite* complete
  181. > #0 0 * * * /usr/sbin/logrotate /var/www/discourse/config/logrotate.conf
  182. > ## Email setup
  183. > IMPORTANT: Discourse relies heavily on email. If your email configuration is not correct, you will effectively have a broken forum.
  184. > Please, head over to our [Mail Setup Guide](https://github.com/discourse/discourse/blob/master/docs/INSTALL-email.md) to find out more information on how to properly setup emails.
  185. > Congratulations! You've got Discourse installed and running!
  186. > ## Administrator account
  187. > Now make yourself an administrator account. Browse to your Discourse instance
  188. > and create an account by logging in normally, then run the commands:
  189. > # Run these commands as the discourse user
  190. > cd /var/www/discourse
  191. > RAILS_ENV=production bundle exec rails c
  192. > # Administratorize yourself:
  193. > # (in rails console)
  194. > > me = User.find_by_username_or_email('myemailaddress@me.com')
  195. > > me.activate # use this in case you haven't configured your mail server and therefore can't receive the activation mail.
  196. > > me.admin = true
  197. > > me.save
  198. > # Mark yourself as the 'system user':
  199. > # (in rails console)
  200. > > SiteSetting.site_contact_username = me.username
  201. > At this point we recommend you start going through the various items in the
  202. > [Discourse Admin Quick Start Guide](https://github.com/discourse/discourse/wiki/The-Discourse-Admin-Quick-Start-Guide)
  203. > to further prepare your site for users.
  204. > ## Site localization
  205. > Custom assets such as images should be placed somewhere under:
  206. > /var/www/discourse/public/
  207. > For example, create a `local` directory and place it into:
  208. > /var/www/discourse/public/uploads/local/michael.png
  209. > The corresponding site setting is:
  210. > logo_small_url: /uploads/local/michael.png
  211. > ## Updating Discourse
  212. > # Run these commands as the discourse user
  213. > bluepill stop
  214. > bluepill quit
  215. > # Back up your install
  216. > DATESTAMP=$(TZ=UTC date +%F-%T)
  217. > pg_dump --no-owner --clean discourse_prod | gzip -c > ~/discourse-db-$DATESTAMP.sql.gz
  218. > tar cfz ~/discourse-dir-$DATESTAMP.tar.gz -C /var/www discourse
  219. > # get the latest Discourse code
  220. > cd /var/www/discourse
  221. > git checkout master
  222. > git pull
  223. > git fetch --tags
  224. > # To run on the latest numbered release instead of bleeding-edge:
  225. > #git checkout latest-release
  226. > #
  227. > # Follow the section below titled:
  228. > # "Check sample configuration files for new settings"
  229. > #
  230. > bundle install --without test --deployment
  231. > RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production bundle exec rake db:migrate
  232. > RUBY_GC_MALLOC_LIMIT=90000000 RAILS_ENV=production bundle exec rake assets:precompile
  233. > # restart bluepill
  234. > crontab -l
  235. > # Here, run the command to start bluepill.
  236. > # Get it from the crontab output above.
  237. > ### Check sample configuration files for new settings
  238. > Check the sample configuration files provided in the repo with the ones being used for additional recommended settings and merge those in:
  239. > # Run these commands as the discourse user
  240. > cd /var/www/discourse
  241. > diff -u config/discourse_defaults.conf config/discourse.conf
  242. > #### Example 1
  243. > $ diff -u config/discourse.pill.sample config/discourse.pill
  244. > --- config/discourse.pill.sample 2013-07-15 17:38:06.501507001 +0000
  245. > +++ config/discourse.pill 2013-07-05 06:38:27.133506896 +0000
  246. > @@ -46,7 +46,7 @@
  247. > app.working_dir = rails_root
  248. > sockdir = "#{rails_root}/tmp/sockets"
  249. > - File.directory? sockdir or FileUtils.mkdir_p sockdir
  250. > + File.directory? sockdir or Dir.mkdir sockdir
  251. > num_webs.times do |i|
  252. > app.process("thin-#{i}") do |process|
  253. > This change reflects us switching to using `FileUtils.mkdir_p` instead of `Dir.mkdir`.
  254. > #### Example 2
  255. > $ diff -u config/nginx.sample.conf /etc/nginx/conf.d/discourse.conf
  256. > --- config/nginx.sample.conf 2013-07-15 17:38:06.521507000 +0000
  257. > +++ /etc/nginx/conf.d/discourse.conf 2013-07-15 17:52:46.649507024 +0000
  258. > @@ -12,17 +12,18 @@
  259. > gzip_min_length 1000;
  260. > gzip_types application/json text/css application/x-javascript;
  261. > - server_name enter.your.web.hostname.here;
  262. > + server_name webtier.discourse.org;
  263. > sendfile on;
  264. > keepalive_timeout 65;
  265. > - client_max_body_size 2m;
  266. > location / {
  267. > root /home/discourse/discourse/public;
  268. > This change reflects a change in placeholder information plus (importantly)
  269. > adding the `client_max_body_size 2m;` directive to the nginx configuration.
  270. > This change should also be made to your production file.
  271. > ## Security
  272. > We take security very seriously at Discourse, and all our code is 100% open source and peer reviewed.
  273. > Please read [our security guide](https://github.com/discourse/discourse/blob/master/docs/SECURITY.md) for an overview of security measures in Discourse.