2013-02-13 00:18:59 +08:00
# Discourse Advanced Developer Install Guide
2013-08-24 19:31:02 +08:00
This guide is aimed at advanced Rails developers who have installed their own Rails apps before. If you are new to Rails, you are likely much better off with our ** [Discourse Vagrant Developer Guide ](VAGRANT.md )**.
Note: If you are developing on a Mac, you will probably want to look at [these instructions ](DEVELOPMENT-OSX-NATIVE.md ) as well.
2013-02-13 00:18:59 +08:00
2016-06-02 02:42:05 +08:00
# Preparing a fresh Ubuntu install
2016-06-11 22:01:35 +08:00
To get your Ubuntu 16.04 LTS install up and running to develop Discourse and Discourse plugins follow the commands below. We assume an English install of Ubuntu.
2016-06-02 02:42:05 +08:00
# Basics
whoami > /tmp/username
sudo add-apt-repository ppa:chris-lea/redis-server
sudo apt-get -yqq update
2016-10-16 02:08:14 +08:00
sudo apt-get -yqq install python-software-properties vim curl expect debconf-utils git-core build-essential zlib1g-dev libssl-dev openssl libcurl4-openssl-dev libreadline6-dev libpcre3 libpcre3-dev imagemagick postgresql postgresql-contrib-9.5 libpq-dev postgresql-server-dev-9.5 redis-server advancecomp gifsicle jhead jpegoptim libjpeg-turbo-progs optipng pngcrush pngquant gnupg2
2016-06-02 02:42:05 +08:00
# Ruby
curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
2016-06-03 01:06:04 +08:00
curl -sSL https://get.rvm.io | bash -s stable
2016-06-02 02:42:05 +08:00
echo 'gem: --no-document' >> ~/.gemrc
2016-06-03 01:06:04 +08:00
2017-07-31 17:09:09 +08:00
# exit the terminal and open it again to activate RVM
2016-06-03 01:06:04 +08:00
2017-07-31 17:09:09 +08:00
rvm install 2.3.4
rvm --default use 2.3.4 # If this error out check https://rvm.io/integration/gnome-terminal
2016-06-02 02:42:05 +08:00
gem install bundler mailcatcher
# Postgresql
2017-10-03 22:25:08 +08:00
sudo -u postgres -i
createuser --superuser -Upostgres $(cat /tmp/username)
2016-06-02 02:42:05 +08:00
psql -c "ALTER USER $(cat /tmp/username) WITH PASSWORD 'password';"
2016-06-03 01:06:04 +08:00
exit
2013-02-13 00:18:59 +08:00
2016-06-02 02:42:05 +08:00
# Node
2017-07-31 17:09:09 +08:00
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
# exit the terminal and open it again to activate NVM
nvm install node
nvm alias default node
2016-06-02 02:42:05 +08:00
npm install -g svgo phantomjs-prebuilt
2013-02-13 00:18:59 +08:00
2014-06-04 07:18:32 +08:00
2016-06-02 02:42:05 +08:00
If everything goes alright, let's clone Discourse and start hacking:
2014-06-04 07:18:32 +08:00
2016-06-02 02:42:05 +08:00
git clone https://github.com/discourse/discourse.git ~/discourse
cd ~/discourse
bundle install
2017-10-03 22:25:08 +08:00
# run this if there was a pre-existing database
bundle exec rake db:drop
RAILS_ENV=test bundle exec rake db:drop
# time to create the database and run migrations
bundle exec rake db:create db:migrate
RAILS_ENV=test bundle exec rake db:create db:migrate
2017-07-31 17:09:09 +08:00
# run the specs (optional)
bundle exec rake autospec # CTRL + C to stop
# launch discourse
bundle exec rails s -b 0.0.0.0 # open browser on http://localhost:3000 and you should see Discourse
2013-03-25 11:49:22 +08:00
2017-10-03 06:08:07 +08:00
Create an admin account with:
2014-07-01 22:12:52 +08:00
2017-10-03 06:08:07 +08:00
bundle exec rake admin:create
2014-07-01 22:12:52 +08:00
2017-10-03 22:25:08 +08:00
If you ever need to recreate your database:
bundle exec rake db:drop db:create db:migrate
bundle exec rake admin:create
RAILS_ENV=test bundle exec rake db:drop db:create db:migrate
2016-06-02 02:42:05 +08:00
Discourse does a lot of stuff async, so it's better to run sidekiq even on development mode:
2013-03-25 11:49:22 +08:00
2017-10-03 06:12:35 +08:00
mailcatcher # open http://localhost:1080 to see the emails, stop with pkill -f mailcatcher
2017-07-25 14:55:22 +08:00
bundle exec sidekiq # open http://localhost:3000/sidekiq to see queues
2016-06-02 02:42:05 +08:00
bundle exec rails server
2013-03-25 11:49:22 +08:00
2016-06-02 02:42:05 +08:00
And happy hacking!