Installation in a development environment
1. Connect to the PostgreSQL DBMS using psql -U postgres and create the discourse_development database and the discourse_user user , to whom we grant access rights to this database.
create database discourse_development;
create user discourse_user;
alter user discourse_user with encrypted password 'your_preferred_password';
alter database discourse_development owner to discourse_user;
Then, also in the psql console, connect to the created database, execute a couple of commands and exit.
\c discourse_development;
create extension hstore;
create extension pg_trgm;
\q
2. Clone the discourse files . If your PostgreSQL version is lower than 12 ( psql --version ), roll them back to version 2.4.0.beta11 , which was released on February 13, 2020 (if I read the git log correctly ).
For this. firstly, there is a team
git clone https://github.com/discourse/discourse.git
To rollback to the February version, enter
git checkout 2136d4b5d535ca1fb83bd015502741d53301a61f
3. Install the gems with the bundle install command , after deleting / renaming Gemfile.lock
4. In config / database.yml, add the username and password values , as well as the encoding: utf8 and template: template0 lines and run bundle exec rake db: migrate .
5. Start the web server for Rails with the command
UNICORN_PORT=3002 bundle exec unicorn -c config/unicorn.conf.rb
6. Set up a reverse proxy server nginx, add in config / environments / development.rb line
config.hosts << "discourse.domain.name"
Screenshot 1. The contents of the file /etc/nginx/sites-enabled/discourse.conf
Note 1 Lines location / assets / {... and the location / images / {... are needed to run in a production environment, it's actually too early to add them to run in a development environment.
Restart nginx with the command /etc/init.d/nginx restart
7. Restart unicorn : to stop, enter kill -QUIT `cat tmp / pids / unicorn.pid`, to restart, enter the command from item 5. Done.
Installation in a development environment
1. We create a database in the same way, only the name of the database is specified not discourse_development , but discourse .
2. Create the config / discourse.conf file with the command
cp config/discourse_defaults.conf config/discourse.conf
Then we specify the values db_name , db_username , db_password , as well as hostname (discourse, discourse_user, your_preferred_password, discourse.domain.name, respectively) in it.
3. Install the required packages with the command
sudo apt install optipng pngquant jhead jpegoptim gifsicle
and execute the command, for the execution of which we installed them without errors:
RAILS_ENV=production bundle exec rake db:migrate
4. Install one more package necessary for the next command using
sudo apt install brotli
and enter the command, for which we installed it without errors
RAILS_ENV=production bundle exec rake assets:precompile
5. Add the lines location / assets / {... and location / images / {... (see screenshot 1) to the nginx configuration file , if they are not there yet, and restart nginx .
6. Stop unicorn (see the command above) and start it in the production environment with the command
RAILS_ENV=production UNICORN_PORT=3002 bundle exec unicorn -c config/unicorn.conf.rb
Sidekiq launch
1. Create an administrator account with the command
RAILS_ENV=production bundle exec rake admin:create
and restart unicorn .
2. To run sidekiq in the config / sidekiq.yml file, copy the configuration lines for the development environment for the production environment (see screenshot 2) and add the line to config / environments / production.rb (in the case when Redis 3.0.6 is installed on the OS)
Redis.exists_returns_integer = false
Screenshot 2.
After that, run sidekiq with the command
bundle exec sidekiq -C config/sidekiq.yml
3. Check the existence of the running process sidekiq with the command
ps aux | grep sidekiq
Initial setup
By opening the address of your forum in the browser and logging into it with the credentials from clause 1 of the "Launching sidekiq" part, you can see the topics on the initial setup and read them.
Screenshot 3. After authorization in discourse
Instructions used when writing the article :
Install Discourse Forum Software on Ubuntu 18.04 Without Docker