Fedora Linux에서 개발용 Discourse 설정하기

이 가이드는 Fedora 31과 33의 새 설치 환경에서 테스트되었지만, dnf를 패키지 관리 도구로 사용하는 이전 버전에서도 작동할 수 있습니다. 이는 공식 가이드는 아니지만 Fedora를 사용하는 다른 개발자분들에게 유용할 수 있습니다. 이 가이드는 주로 Ubuntu 개발 가이드를 기반으로 하며, dnf에 맞는 패키지 차이점을 반영하여 수정되었습니다. 이미 패키지가 설치되어 있지 않다고 가정하지만, 이미 설치된 패키지는 대부분 도구가 자동으로 건너뜁니다.

프로덕션 환경에 Discourse를 설치하려는 경우, GitHub의 docker 설치 지침을 우선적으로 따르는 것이 좋습니다.

필수 시스템 및 개발 패키지 설치

sudo dnf update
sudo dnf install -y "@development-tools" git rpm-build zlib-devel ruby-devel readline-devel libpq-devel ImageMagick sqlite sqlite-devel nodejs npm curl gcc g++ bzip2 openssl-devel libyaml-devel libffi-devel zlib-devel gdbm-devel ncurses-devel optipng pngquant jhead jpegoptim gifsicle oxipng

필수 npm 패키지 설치

sudo npm install -g svgo pnpm

Postgres 설치 및 설정

sudo dnf install postgresql-server postgresql-contrib
sudo postgresql-setup --initdb --unit postgresql
sudo systemctl enable postgresql
sudo systemctl start postgresql
sudo -u postgres -i createuser -s $USER

Redis 설치 및 설정

sudo dnf install redis
sudo systemctl enable redis
sudo systemctl start redis

rbenv, ruby-build 및 ruby 설치

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
~/.rbenv/bin/rbenv init
printf 'export PATH="$HOME/.rbenv/bin:$PATH"\n' >> ~/.bashrc
printf 'eval "$(rbenv init - --no-rehash)"\n' >> ~/.bashrc
source ~/.bashrc
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
# 설치가 올바른지 확인
 curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
rbenv install 2.7.1
rbenv global 2.7.1
rbenv rehash

Ruby 의존성 설치

gem update --system
gem install bundler mailcatcher rails

Discourse 코드 클론

git clone https://github.com/discourse/discourse.git ~/discourse
cd ~/discourse

Discourse 의존성 설치

bundle install
pnpm install

필수 데이터베이스 생성 및 스키마 로드

bundle exec rake db:create db:migrate
RAILS_ENV=test bundle exec rake db:create db:migrate

테스트 실행으로 설치 확인

bundle exec rake autospec

애플리케이션 실행

bundle exec rails server

이제 http://localhost:3000에서 Discourse 설정 페이지를 볼 수 있어야 합니다.

추가 설정에 대해서는 기존 공식 설치 가이드를 참고하세요.


이 문서는 버전 관리됩니다. 변경 사항을 GitHub에서 제안할 수 있습니다.

27개의 좋아요

In Installing rbenv, ruby-build, and ruby, the url to the rbenv-doctor script is not working anymore (apparently the branch has been rename from master to main), the correct command is now:

curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
2개의 좋아요

Thanks for the info @nicolas-jaussaud, I’ve updated the OP.

FWIW I now prefer to use chruby and ruby-install over rbenv.

2개의 좋아요

I ran into an issue trying to run bundle install as Fedora now has by default disabled file transport.

The error happens when trying to install the sprockets gem and ends with the message:

transport 'file' not allowed

I don’t know what’s the proper way to do this, but you can temporarily allow the unsafe transport:

git config --global protocol.file.allow always
# run the discourse setup here
git config --global protocol.file.allow never

After that I ran into an error like this when running db:migrate:

At /home/hhyyrylainen/Projects/discourse/lib/site_setting_extension.rb:199:in `public_send`
Deprecation notice: `SiteSetting.enable_personal_messages` has been deprecated. Please use `SiteSetting.personal_message_enabled_groups` instead. (removal in Discourse 3.0) 
At /home/hhyyrylainen/Projects/discourse/lib/site_setting_extension.rb:199:in `public_send`
#<Thread:0x00007f94c3342600 /home/hhyyrylainen/Projects/discourse/lib/scheduler/defer.rb:83 run> terminated with exception (report_on_exception is true):
/home/hhyyrylainen/.gem/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/connection_handling.rb:309:in `connection_pool': ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
	from /home/hhyyrylainen/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rails_multisite-4.0.1/lib/rails_multisite/connection_management/rails_61_compat.rb:8:in `current'
	from /home/hhyyrylainen/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rails_multisite-4.0.1/lib/rails_multisite/connection_management.rb:115:in `current_db_hostnames'
	from /home/hhyyrylainen/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rails_multisite-4.0.1/lib/rails_multisite/connection_management.rb:111:in `current_hostname'
	from /home/hhyyrylainen/Projects/discourse/lib/discourse.rb:232:in `handle_job_exception'
	from /home/hhyyrylainen/Projects/discourse/lib/scheduler/defer.rb:114:in `rescue in do_work'
	from /home/hhyyrylainen/Projects/discourse/lib/scheduler/defer.rb:113:in `do_work'
	from /home/hhyyrylainen/Projects/discourse/lib/scheduler/defer.rb:85:in `block (2 levels) in start_thread'
/home/hhyyrylainen/.gem/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/connection_handling.rb:309:in `connection_pool': ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
	from /home/hhyyrylainen/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rails_multisite-4.0.1/lib/rails_multisite/connection_management.rb:79:in `with_connection'
	from /home/hhyyrylainen/Projects/discourse/lib/scheduler/defer.rb:96:in `do_work'
	from /home/hhyyrylainen/Projects/discourse/lib/scheduler/defer.rb:85:in `block (2 levels) in start_thread'

It seems it happened after the migration finished, so as I couldn’t figure out how to fix that I ignored it, but luckily my development site seems to be working.

For the test environment I didn’t get the same error but got an error about missing oxipng, which doesn’t seem to be available as a Fedora package.

After that I didn’t run into any more issues, everything still more or less worked fine on Fedora 38. Though, I had previously installed rbenv using some other setup instructions.

Running bundle exec rake autospec I got some test failures (135) but it seems I got a mostly working development setup.

2개의 좋아요

I got the Dev version going some time ago but the Production version was too difficult for me . .

Just followed this guide to install on Fedora 40 Workstation, had to add oxipng to the distro installs.
sudo dnf install oxipng

3개의 좋아요

Thanks for letting us know, I’ve updated the documentation in this commit: docs/fedora-setup: include oxipng package (#14) · discourse/discourse-developer-docs@eb51e54 · GitHub.

1개의 좋아요

I am stuck after installation today on Fedora 41 with the following issue when I connect to localhost:3000 and click on register :
“no administrator emails were defined during setup”; the message provides how to add an administrator email.

I’ve failed to successfuly add an admin acount following this procedure because of 2 errors when using ./launcher enter app :
1° First solved error was: no app.yml file is present → I copied the sampleapp.yml from the sample folder to the container folder, then modified to add email adresses, then did the rebuild with /var/discourse/launcher rebuild app
2° Second error is not solved :
Error response from daemon: No such container: app
If I use the rake commands to create an admin it tells me no rakefile found

Can anyone please help?

This install doesn’t use docker, so you can’t enter a container.

Try creating an admin from the Discourse folder with this command:

bin/rails admin:create
1개의 좋아요

Hi Coconut, you are quick to respond and efficient, thanks a lot !
The command returns gem bunder missing, which I installed with `gem install bundler -v 2.6.2’ and then I could successfuly apply your solution !

2개의 좋아요

Just tried running a local install and ran into issues with pgvector. This is on Fedora 42 and Postgres16. The packaged version of pgvector is 0.6.2 and it seems I need to compile from source to get a more recent one.

Then ran into conflicts trying to build pgvector, which seems to require postgresql-private-devel package that had conflicting requests with libpq-devel.

Resolved it by:

  •  sudo dnf install postgresql-server-devel --allowerasing
    
  • Build pgvector
  • Check installed version
    sudo -u postgres psql discourse_development -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';"
    
  •  sudo systemctl restart postgresql
    
3개의 좋아요

image

Soo… is this official? (That line should probably be removed, no?)

Pardon me, but is this version out of date? The most recent version of Ruby listed on rbenv install -l is 4.0.5 IIRC (as is the most recent version on ruby-lang.org)

1개의 좋아요

Running bundle exec rails server, it starts a whole bunch of migrations. It’s been running for about an hour and still not done. My laptop has enough RAM and CPU power for this, is this just because of the sheer amount of migrations needed to be run?

EDIT: 3 hours in and still going strong.
EDIT #2: Into the 4th hour…

EDIT #3: Me being me, I misread the console output for 4 hours and realised now that it’s not actually migrations running :facepalm: … it’s the Sidekiq jobs… and port 3000 actually shows the instance. No cause for alarm!