Install Discourse on Ubuntu or Debian for Development

:warning: This guide covers installation instructions in a development environment. For a production guide see: Install Discourse in production with the official, supported instructions


So you want to set up Discourse on Ubuntu or Debian to hack on and develop with?

We’ll assume that you work locally and don’t have Ruby/Rails/Postgres/Redis installed on your Ubuntu or Debian system. Let’s begin!

Requirements

We suggest having at least 4 GB RAM and 2 CPU cores.

Current compatibility:

OS Compatibility
Debian 11 :white_check_mark:
Crostini (Linux on ChromeOS) :white_check_mark:
Ubuntu 22.04 or later :white_check_mark:

Install Discourse Dependencies

As regular user run this script in terminal, to setup Rails development environment:-

bash <(wget -qO- https://raw.githubusercontent.com/discourse/install-rails/main/linux)

This will install the following new packages on your system:

In case you have any of this package pre-installed and don’t want to run the entire script, see the script and pick the packages you don’t have currently installed. The script is fine-tuned for Discourse, and includes all the packages required for Discourse installation.

Now that we have installed Discourse dependencies, let’s move on to install Discourse itself.

Clone Discourse

Clone the Discourse repository in ~/discourse folder:

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

~ indicates home folder, so Discourse source code will be available in your home folder.

Setup Database

Already completed by the install script

Create role with the same name as your Linux system username:

cd /tmp && sudo -u postgres createuser -s "$USER"

Bootstrap Discourse

Switch to your Discourse folder:

 cd ~/discourse

Install the needed gems

source ~/.bashrc
bundle install

Install the JS dependencies

yarn install

Now that you have successfully installed gems, run these commands:

bin/rails db:create 
bin/rails db:migrate
RAILS_ENV=test bin/rails db:create db:migrate

Start rails and ember server:

bin/ember-cli -u

If the images are not appearing, use this command instead:
(you can also specify an IP if you are working on a remote server)

DISCOURSE_HOSTNAME=localhost UNICORN_LISTENER=localhost:3000 bin/ember-cli -u

You should now be able to navigate to http://localhost:4200 to see your local Discourse installation.

Create New Admin

To create a new admin, run the following command:

bin/rails admin:create

Follow the prompts, and a new admin account will be created.

Configure Mail

Run MailHog:

mailhog

Congratulations! You are now the admin of your own Discourse installation!

Happy hacking! And to get started with that, see Beginner’s Guide to Creating Discourse Plugins.


Last Reviewed by @blake on 2023-04-03T06:00:00Z

Last edited by @JammyDodger 2024-05-25T08:33:27Z

Check documentPerform check on document:
63 Likes

fixed it by removing the calendar plugin. :thinking:

3 Likes

install is very slow

I’ve been trying for about 45min to get it to connect to my local DB but can’t figure it out:

discourse $bin/rails db:create
We could not find your database: postgres. Which can be found in the database configuration file located at config/database.yml

Here is the full trace:

discourse $bin/rails db:create --trace
** Invoke db:create (first_time)
** Invoke db:force_skip_persist (first_time)
** Execute db:force_skip_persist
** Invoke db:load_config (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:load_config
** Execute db:create
We could not find your database: postgres. Which can be found in the database configuration file located at config/database.yml.

To resolve this issue:

- Did you create the database for this app, or delete it? You may need to create your database.
- Has the database name changed? Check your database.yml config has the correct database name.

To create your database, run:

        bin/rails db:create
Couldn't create 'discourse_development' database. Please check your configuration.
rails aborted!
ActiveRecord::NoDatabaseError: We could not find your database: postgres. Which can be found in the database configuration file located at config/database.yml. (ActiveRecord::NoDatabaseError)

To resolve this issue:

- Did you create the database for this app, or delete it? You may need to create your database.
- Has the database name changed? Check your database.yml config has the correct database name.

To create your database, run:

        bin/rails db:create
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/postgresql_adapter.rb:81:in `rescue in new_client'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/postgresql_adapter.rb:77:in `new_client'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:in `public_send'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:in `new_connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:700:in `checkout_new_connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:679:in `try_to_checkout_new_connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:640:in `acquire_connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:341:in `checkout'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:181:in `connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_handler.rb:211:in `retrieve_connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_handling.rb:313:in `retrieve_connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_handling.rb:280:in `connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/postgresql_database_tasks.rb:12:in `connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/postgresql_database_tasks.rb:26:in `create'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/database_tasks.rb:122:in `create'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/database_tasks.rb:184:in `block in create_current'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/discourse_dev_assets-0.0.4/lib/discourse_dev_assets.rb:27:in `block in each_current_configuration'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/database_tasks.rb:557:in `block (2 levels) in each_current_configuration'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/database_tasks.rb:554:in `each'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/database_tasks.rb:554:in `block in each_current_configuration'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/database_tasks.rb:553:in `each'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/database_tasks.rb:553:in `each_current_configuration'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/discourse_dev_assets-0.0.4/lib/discourse_dev_assets.rb:22:in `each_current_configuration'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/database_tasks.rb:184:in `create_current'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/railties/databases.rake:45:in `block (2 levels) in <main>'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:281:in `block in execute'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:281:in `each'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:281:in `execute'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:199:in `synchronize'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:188:in `invoke'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:188:in `invoke_task'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:138:in `block (2 levels) in top_level'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:138:in `each'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:138:in `block in top_level'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:147:in `run_with_threads'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:132:in `top_level'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:214:in `standard_exception_handling'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/rake_module.rb:59:in `with_application'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/command.rb:51:in `invoke'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/commands.rb:18:in `<main>'
<internal:/home/dylan/.rbenv/versions/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
<internal:/home/dylan/.rbenv/versions/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
bin/rails:18:in `<main>'

Caused by:
PG::ConnectionBad: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: fe_sendauth: no password supplied (PG::ConnectionBad)
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/pg-1.5.4/lib/pg/connection.rb:696:in `async_connect_or_reset'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/pg-1.5.4/lib/pg/connection.rb:824:in `connect_to_hosts'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/pg-1.5.4/lib/pg/connection.rb:759:in `new'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/pg-1.5.4/lib/pg.rb:63:in `connect'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/postgresql_adapter.rb:78:in `new_client'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:in `public_send'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:in `new_connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:700:in `checkout_new_connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:679:in `try_to_checkout_new_connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:640:in `acquire_connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:341:in `checkout'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:181:in `connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_adapters/abstract/connection_handler.rb:211:in `retrieve_connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_handling.rb:313:in `retrieve_connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/connection_handling.rb:280:in `connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/postgresql_database_tasks.rb:12:in `connection'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/postgresql_database_tasks.rb:26:in `create'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/database_tasks.rb:122:in `create'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/database_tasks.rb:184:in `block in create_current'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/discourse_dev_assets-0.0.4/lib/discourse_dev_assets.rb:27:in `block in each_current_configuration'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/database_tasks.rb:557:in `block (2 levels) in each_current_configuration'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/database_tasks.rb:554:in `each'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/database_tasks.rb:554:in `block in each_current_configuration'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/database_tasks.rb:553:in `each'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/database_tasks.rb:553:in `each_current_configuration'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/discourse_dev_assets-0.0.4/lib/discourse_dev_assets.rb:22:in `each_current_configuration'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/tasks/database_tasks.rb:184:in `create_current'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activerecord-7.0.8.1/lib/active_record/railties/databases.rake:45:in `block (2 levels) in <main>'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:281:in `block in execute'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:281:in `each'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:281:in `execute'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:199:in `synchronize'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:199:in `invoke_with_call_chain'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/task.rb:188:in `invoke'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:188:in `invoke_task'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:138:in `block (2 levels) in top_level'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:138:in `each'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:138:in `block in top_level'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:147:in `run_with_threads'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:132:in `top_level'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/application.rb:214:in `standard_exception_handling'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rake-13.2.1/lib/rake/rake_module.rb:59:in `with_application'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/command.rb:51:in `invoke'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/railties-7.0.8.1/lib/rails/commands.rb:18:in `<main>'
<internal:/home/dylan/.rbenv/versions/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
<internal:/home/dylan/.rbenv/versions/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
/home/dylan/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
bin/rails:18:in `<main>'
Tasks: TOP => db:create

Hello. Try to install on ubuntu server 24, and can not install imagemagick:

console log
install-imagemagick                                         100%[========================================================================================================================================>]   2.57K  --.-KB/s    in 0s


2024-06-23 14:08:00 (13.4 MB/s) - ‘install-imagemagick’ saved [2631/2631]

Reading package lists...
Building dependency tree...
Reading state information...
Package 'imagemagick' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package libwebp6
E: Unable to locate package libltdl7-dev

Looks like on ubuntu need to be installed libwebp7 not libwebp6, but in script exist check libwebp version for ubuntu 22 only:

# Ubuntu 22.04/22.10  doesn't have libwebp6
LIBWEBP=$(cat /etc/issue | grep -qi 'Ubuntu 22' && echo 'libwebp7' || echo 'libwebp6')

I think, this code must be edited to instal libwebp7 in any way…

1 Like

I have the same problem. Any suggestions?

I download main script:
https://raw.githubusercontent.com/discourse/install-rails/main/linux

and download install-imagemagick

In script install-imagemagick I edit string 12
from:
LIBWEBP=$(cat /etc/issue | grep -qi 'Ubuntu 22' && echo 'libwebp7' || echo 'libwebp6')
to
LIBWEBP=$(cat /etc/issue | grep -qi 'Ubuntu 22' && echo 'libwebp7' || echo 'libwebp7')

Also I edit at 105 string in main script, where it calling install-imagemagick script, so, in this line, my edited install-imagemagick installation file would be called, and not the original one.

1 Like

Now I have new error:

The value 'bullseye-backports' is invalid for APT::Default-Release as such a release is not available in the sources
failed

I give up…
I think it should be noted here that the instructions from the first post not actual at this time.
Will try with docker

I did a PR a while back to add support for Ubuntu 20 and Debian 12. I guess I will need to revisit it.

For Ubuntu 24, you would need to change the regular expressions to something like:
grep -qiE 'Ubuntu 2[2-9]'

You can remove the check as I did in the PR.


You can use this updated version, in your case:

#!/bin/bash
set -e

# version check: https://github.com/ImageMagick/ImageMagick/releases
IMAGE_MAGICK_VERSION="7.1.0-62"
IMAGE_MAGICK_HASH="d282117bc6d0e91ad1ad685d096623b96ed8e229f911c891d83277b350ef884a"

# We use debian, but GitHub CI is stuck on Ubuntu Bionic, so this must be compatible with both
LIBJPEGTURBO=$(cat /etc/issue | grep -qi Debian && echo 'libjpeg62-turbo libjpeg62-turbo-dev' || echo 'libjpeg-turbo8 libjpeg-turbo8-dev')

# Ubuntu 22/23/24 and Debian 12 don't have libwebp6
LIBWEBP=$(cat /etc/issue | grep -qiE 'Ubuntu 22|Debian.*12' && echo 'libwebp7' || echo 'libwebp6')

PREFIX=/usr/local
WDIR=/tmp/imagemagick

# Install build deps
apt -y -q remove imagemagick
apt -y -q install git make gcc pkg-config autoconf curl g++ yasm cmake \
    libde265-0 libde265-dev ${LIBJPEGTURBO} x265 libx265-dev libtool \
    libpng16-16 libpng-dev ${LIBJPEGTURBO} ${LIBWEBP} libwebp-dev libgomp1 \
    libwebpmux3 libwebpdemux2 ghostscript libxml2-dev libxml2-utils librsvg2-dev \
    libltdl7-dev libbz2-dev gsfonts libtiff-dev libfreetype6-dev libjpeg-dev

apt -y install libheif1 libaom-dev libheif-dev

mkdir -p $WDIR
cd $WDIR

# Build and install ImageMagick
wget -q -O $WDIR/ImageMagick.tar.gz "https://github.com/ImageMagick/ImageMagick/archive/$IMAGE_MAGICK_VERSION.tar.gz"
sha256sum $WDIR/ImageMagick.tar.gz
echo "$IMAGE_MAGICK_HASH $WDIR/ImageMagick.tar.gz" | sha256sum -c
IMDIR=$WDIR/$(tar tzf $WDIR/ImageMagick.tar.gz --wildcards "ImageMagick-*/configure" |cut -d/ -f1)
tar zxf $WDIR/ImageMagick.tar.gz -C $WDIR
cd $IMDIR
PKG_CONF_LIBDIR=$PREFIX/lib LDFLAGS=-L$PREFIX/lib CFLAGS=-I$PREFIX/include ./configure \
          --prefix=$PREFIX \
          --enable-static \
          --enable-bounds-checking \
          --enable-hdri \
          --enable-hugepages \
          --with-threads \
          --with-modules \
          --with-quantum-depth=16 \
          --without-magick-plus-plus \
          --with-bzlib \
          --with-zlib \
          --without-autotrace \
          --with-freetype \
          --with-jpeg \
          --without-lcms \
          --with-lzma \
          --with-png \
          --with-tiff \
          --with-heic \
          --with-rsvg \
          --with-webp
make all && make install

cd $HOME
rm -rf $WDIR
ldconfig /usr/local/lib

# Validate ImageMagick install
test $(convert -version | grep -o -e png -e tiff -e jpeg -e freetype -e heic -e webp | wc -l) -eq 6
3 Likes

Yes. Its working, thank you! I have some doubt question. How I can configure discourse to use it from LAN for debug? My ubuntu is Hyper-V Ubuntu Server, so, I use not “localhost” for accessing discourse, but local ip address (192.168.2.20 in my case), from another PC browser, and all “self hosted” images is not accessebly with error - 404 (because they have url - //localhost:4200/uploads/default/original/2X/8/81ce02e47fa4b791e9cb4b880c6c4dab9e0b6d9d.png), and of cause its not worked from LAN)

2 posts were split to a new topic: Docker-less production install

TL;DR: Please merge #750. Legacy systems always comes with trouble.

Casually phrased, the instructions do state:

In case anyone else makes the mistake of believing it is just a friendly suggestion, please think again. Any attempt to launch with 1 GiB RAM and 4 GiB of swap will result, not in degraded performance, but in:

Error compiling CSS asset

RuntimeError: Discourse does not support compiling scss/sass files via Sprockets

…/discourse/config/application.rb:190:in `call’

Which according to this thread is a symptom of an insufficient RAM allocation.

Eventually one might also be lucky enough to get a JavaScript stack trace starting with:

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

So follow the instructions! I’m off to redo this exercise with a freshly created VPS. Rather than attempting to mock around with setting up something as old and outdated, I instead tried repurposing an old decommissioned bullseye one I happened to have still running.

Maybe a second reviewer would wish to look at that PR adding bookworm support, so I’ll be the last sucker getting hit by this?

I made a second attempt, on an Ubuntu 22.04.4 LTS (Jammy Jellyfish), and now seem to have a working development environment. That took a couple of attempts though, since the instructions lack one very important command.

A crucial step before running ./linux is to create them gem cache directory:

mkdir --parent /home/discourse/.cache/gem

Missing that step will cause the directory to be created with root:root permissions, which makes the installation fail when running it with a freshly created user account.