Linux
Installing Forem on Linux
Installing prerequisites​
These prerequisites assume you're working on a Linux-based operating system, but they have only been tested on Ubuntu 18.04.
Ruby​
- If you don't already have a Ruby version manager, we highly recommend rbenv. Please follow their installation guide.
- With the Ruby version manager, install the Ruby version listed on our badge.
(ie with rbenv:
rbenv install $(cat .ruby-version)
)
For very detailed rbenv installation directions on several distros, please visit DigitalOcean's guide.
Yarn​
There are two ways to install Yarn.
- Yarn's official installation guide (recommended).
- DigitalOcean's detailed tutorial
describes how to install
Node version Manager. By installing NVM
you can select a Node version, use
16
(matches Forem's .nvmrc and package.json files); the guide will also explain how to install NPM. This way you'll have Node, NPM, and then you can runnpm install -g yarn
to install Yarn.
PostgreSQL​
Forem requires PostgreSQL version 11 or higher.
- Run
sudo apt update && sudo apt install postgresql postgresql-contrib libpq-dev
. - To test the installation you can run
sudo -u postgres psql
which should open a PostgreSQL prompt. Exit the prompt by running\q
then runsudo -u postgres createuser -s $YOUR_USERNAME
where$YOUR_USERNAME
is the username you are currently logged in as.
There are more than one ways to setup PostgreSQL. For additional configuration, check out our PostgreSQL setup guide or the official PostgreSQL site for further information.
ImageMagick​
Forem uses ImageMagick to manipulate images on upload.
Please refer to ImageMagick's instructions on how to install it.
Redis​
Forem requires Redis version 6.0 or higher.
We recommend following Digital Ocean's extensive guides How to Install and Secure Redis to setup Redis.
Installing Forem​
Fork Forem's repository, e.g. https://github.com/forem/forem/fork
Clone your forked repository, e.g.
git clone https://github.com/<your-username>/forem.git
Install bundler with
gem install bundler
Set up your environment variables/secrets
Take a look at
.env_sample
. This file lists all theENV
variables we use and provides a fake default for any missing keys.If you use a remote computer as dev env, you need to set
APP_DOMAIN
variable to the remote computer's domain name.The backend guide will show you how to get free API keys for additional services that may be required to run certain parts of the app.
For any key that you wish to enter/replace:
- Create
.env
by copying from the provided template (i.e. with bash:cp .env_sample .env
). This is a personal file that is ignored in git. If you don't need to override any environment variables, continue with the next step as our setup script will automatically create a default.env
file. - Obtain the development variable and apply the key you wish to enter/replace. i.e.:
export CLOUDINARY_API_KEY="SOME_REAL_SECURE_KEY_HERE"
export CLOUDINARY_API_SECRET="ANOTHER_REAL_SECURE_KEY_HERE"
export CLOUDINARY_CLOUD_NAME="A_CLOUDINARY_NAME"- Create
You do not need "real" keys for basic development. Some features require certain keys, so you may be able to add them as you go. The test environment is isolated from changes to the .env file, if you want to set variables in both test and development, use a file named .env.local, or modify .env.test.local and .env.development.local.
Run
bin/setup
Possible error messages​
While installing, you might run into an error due to the pg
gem requiring
PostgreSQL libraries. If so, please run sudo apt-get install libpq-dev
before
retrying.
While installing, you might run into an error due to the sass-rails
gem
requiring sassc
, which requires the g++
compiler. If so, please run
sudo apt-get install g++
before retrying.
While installing, if you didn't install node
or nvm
manually, you might run
into an error due to an older system node version being present, which can cause
issues while yarn
is installing packages. If so, you'll need to
install nvm
and then
run nvm install node
to get the most recent node version before retrying.