Editing Moebooru
From Bibliotheca Anonoma
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
'''Moebooru''' is a well maintained Danbooru-style image tag system, used by Yande.re, Konachan, and many others. It is written in Ruby, and can be a bit of a challenge to install. Since many other installation guides are insufficient, we've noted down our entire installation and configuration process for [https://booru.eikonos.org Eikonos]. | '''Moebooru''' is a well maintained Danbooru-style image tag system, used by Yande.re, Konachan, and many others. It is written in Ruby, and can be a bit of a challenge to install. Since many other installation guides are insufficient, we've noted down our entire installation and configuration process for [https://booru.eikonos.org Eikonos]. | ||
Line 35: | Line 33: | ||
sudo chown moe:moe /home/moe/booru/public | sudo chown moe:moe /home/moe/booru/public | ||
sudo chmod 755 /var/www/moebooru/public | sudo chmod 755 /var/www/moebooru/public | ||
sudo chown | sudo chown nginx:nginx -R /var/www/moebooru | ||
|lang=bash}} | |lang=bash}} | ||
Line 62: | Line 60: | ||
{{ic|libpqxx}} is required for libpq-ruby to build. | {{ic|libpqxx}} is required for libpq-ruby to build. | ||
Now log in and create the moebooru user: | |||
Now log in and create the moebooru | |||
<pre># su - postgres | |||
# su - postgres | |||
$ psql | $ psql | ||
postgres # | postgres # create user moebooru_user with password 'the_password' createdb;</pre> | ||
Finally, edit {{ic|pg_hba.conf}} from {{ic|ident}} to {{ic|md5}} (except for the UNIX socket line) to allow users to log in using a password (required by moebooru's config), it should look like the following: | Finally, edit {{ic|pg_hba.conf}} from {{ic|ident}} to {{ic|md5}} (except for the UNIX socket line) to allow users to log in using a password (required by moebooru's config), it should look like the following: | ||
Line 108: | Line 97: | ||
''For most small sites'', Ruby 2.3 and higher with the Unicorn server is sufficient. | ''For most small sites'', Ruby 2.3 and higher with the Unicorn server is sufficient. | ||
''A site with heavier traffic'' may find it helpful to use Rubinius with the Puma server [https://blog.engineyard.com/2014/ruby-app-server-arena-pt1to make better use of concurrent multithreading,] but this may require compilation | ''A site with heavier traffic'' may find it helpful to use Rubinius with the Puma server [https://blog.engineyard.com/2014/ruby-app-server-arena-pt1to make better use of concurrent multithreading,] but this may require compilation. | ||
=== Method 1: Set up Normal Ruby 2.3 or newer === | === Method 1: Set up Normal Ruby 2.3 or newer === | ||
Line 119: | Line 106: | ||
* RHEL/CentOS: [https://www.softwarecollections.org/en/scls/rhscl/rh-ruby23/ RHSCL - Ruby 2.3] | * RHEL/CentOS: [https://www.softwarecollections.org/en/scls/rhscl/rh-ruby23/ RHSCL - Ruby 2.3] | ||
=== Method 2: | === Method 2: Install Rubinius with RVM === | ||
For RVM, just install any ol' ruby 2.x, we won't be using it after the compilation stage. Also install all the build dependencies. | |||
==== Dependencies (Debian/Ubuntu) ==== | |||
{{bc| | {{bc| | ||
sudo apt-get install ruby | |||
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev \ | |||
curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 \ | |||
libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison \ | |||
subversion pkgconfig | |||
}} | }} | ||
An LLVM version greater than 3.6+ is also required. You can get this in [https://backports.debian.org/Instructions/ Debian Jessie from backports], or in Ubuntu from normal repositories. | |||
{{bc| | {{bc| | ||
# if on debian jessie, set up jessie-backports: https://backports.debian.org/Instructions/ | |||
sudo apt-get install llvm-3.8 clang-3.8 libclang-3.8-dev llvm-3.8-runtime llvm-3.8-dev llvm-3.8-tools libedit libedit-dev | |||
}} | }} | ||
==== Dependencies (RHEL/CentOS) ==== | |||
=== | |||
{{bc| | {{bc| | ||
sudo yum install ruby | sudo yum install ruby | ||
sudo yum install -y patch autoconf patch automake libtool bison sqlite | sudo yum install -y patch autoconf patch automake libtool bison sqlite-devel | ||
}} | }} | ||
Line 204: | Line 155: | ||
}} | }} | ||
==== Using RVM ==== | |||
{{ | {{Note|Make sure to run all these steps as the moebooru user.}} | ||
http://rayhightower.com/blog/2014/02/06/installing-rubinius-using-rvm/ | |||
The right way to use it is just plain jane on the server. Installation is easy using rvm. Run these as the current user: | |||
Refresh the rvm repos | Refresh the rvm repos: | ||
{{bc| | {{bc| | ||
rvm get head | rvm get head | ||
}} | }} | ||
Line 261: | Line 202: | ||
{{Note|If you change ruby editions later on after installing gems, make sure to run {{ic|gem pristine --all}} to delete the previous ones. After that, reinstall all gems from scratch.}} | {{Note|If you change ruby editions later on after installing gems, make sure to run {{ic|gem pristine --all}} to delete the previous ones. After that, reinstall all gems from scratch.}} | ||
<!-- | <!-- | ||
==== Setup Rubinius with Zonio Repo (RHEL/CentOS) ==== | ==== Setup Rubinius with Zonio Repo (RHEL/CentOS) ==== | ||
Line 352: | Line 243: | ||
https://zonio.net/rubinius_rpm_packages/ | https://zonio.net/rubinius_rpm_packages/ | ||
--> | --> | ||
== Mandatory Access Control == | == Mandatory Access Control == | ||
Line 360: | Line 249: | ||
anyone have apparmor profiles? | anyone have apparmor profiles? | ||
=== SELinux Permissions (RHEL/CentOS) === | === SELinux Permissions (RHEL/CentOS) === | ||
Line 417: | Line 304: | ||
=== Configure Moebooru === | === Configure Moebooru === | ||
First, [http://stackoverflow.com/a/9235107 do a bundle config for pg] since we're using a specific postgresql version: | |||
{{bc| | {{bc|<nowiki>bundle config build.pg --with-pg-config=/usr/pgsql-9.6/bin/pg_config</nowiki>}} | ||
Generate your secret key, which is used for salts and such. | |||
{{bc| | {{bc|bundle exec rake secret}} | ||
bundle | |||
Install the ruby packages for the moebooru user only (under the directory <code>./vendor/bundle</code>): | Install the ruby packages for the moebooru user only (under the directory <code>./vendor/bundle</code>): | ||
Line 435: | Line 319: | ||
{{bc| | {{bc| | ||
cp config/database.yml.example config/database.yml | $ cp config/database.yml.example config/database.yml | ||
cp config/local_config.rb.example config/local_config.rb | $ cp config/local_config.rb.example config/local_config.rb | ||
chmod 700 config/database.yml | $ chmod 700 config/database.yml | ||
chmod 700 config/local_config.rb | $ chmod 700 config/local_config.rb | ||
}} | }} | ||
Edit {{ic|config/database.yml}} using your favorite editor (such as nano), and replace {{ic|imouto}} with the password of your database user: | Edit {{ic|config/database.yml}} using your favorite editor (such as nano), and replace {{ic|imouto}} with the password of your database user: | ||
Line 469: | Line 349: | ||
{{bc|chmod 600 /home/moe/booru/config/database.yml}} | {{bc|chmod 600 /home/moe/booru/config/database.yml}} | ||
Initialize database with this command (there will be some errors reported | Initialize database with this command (there will be some errors reported which is expected) | ||
{{bc|bundle exec rake db:reset}} | {{bc|bundle exec rake db:reset}} | ||
{{Note|Whenever you update moebooru using {{ic|git pull}}, make sure to migrate the database table schema with the command below.}} | {{Note|Whenever you update moebooru using {{ic|git pull}}, make sure to migrate the database table schema with the command below.}} | ||
Line 485: | Line 363: | ||
{{bc|chmod 755 /home/moe/booru/public}} | {{bc|chmod 755 /home/moe/booru/public}} | ||
Start the server | Start the server (<code>bundle exec unicorn</code> or <code>bundle exec puma</code> if using JRuby/Rubinius) | ||
== Customize Header Image and Branding == | == Customize Header Image and Branding == | ||
Line 595: | Line 473: | ||
=== Run the Server === | === Run the Server === | ||
Finally, to run the server | Finally, to run the server (default is port 9292), run one of the following commands: | ||
Ruby: | Ruby: | ||
Line 603: | Line 481: | ||
Rubinius: | Rubinius: | ||
{{bc|<nowiki>RAILS_ENV=production bundle exec puma -e production | {{bc|<nowiki>RAILS_ENV=production bundle exec puma -e production</nowiki>}} | ||
* [http://stackoverflow.com/a/27318704 Source: StackOverflow - Rails 4: assets not loading in production] | * [http://stackoverflow.com/a/27318704 Source: StackOverflow - Rails 4: assets not loading in production] | ||
Line 614: | Line 492: | ||
<pre>grep -c processor /proc/cpuinfo</pre> | <pre>grep -c processor /proc/cpuinfo</pre> | ||
Create the following folders in your application directory: | |||
<pre>mkdir -p shared/pids shared/sockets shared/log</pre> | |||
<pre>mkdir -p shared/log</pre> | |||
Place the following into {{ic|<app_dir>/shared/puma.rb}}: | Place the following into {{ic|<app_dir>/shared/puma.rb}}: | ||
Line 633: | Line 503: | ||
threads 1, 6 | threads 1, 6 | ||
app_dir = File.expand_path( | app_dir = File.expand_path("../..", __FILE__) | ||
shared_dir = | shared_dir = "#{app_dir}/shared" | ||
# Default to production | # Default to production | ||
rails_env = ENV['RAILS_ENV'] || | rails_env = ENV['RAILS_ENV'] || "production" | ||
environment rails_env | environment rails_env | ||
# Set up socket location | # Set up socket location | ||
bind | bind "unix://#{shared_dir}/sockets/puma.sock" | ||
# Logging | # Logging | ||
stdout_redirect | stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true | ||
# Set master PID and state locations | # Set master PID and state locations | ||
pidfile | pidfile "#{shared_dir}/pids/puma.pid" | ||
state_path | state_path "#{shared_dir}/pids/puma.state" | ||
activate_control_app | activate_control_app | ||
on_worker_boot do | on_worker_boot do | ||
require | require "active_record" | ||
ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished | ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished | ||
ActiveRecord::Base.establish_connection(YAML.load_file( | ActiveRecord::Base.establish_connection(YAML.load_file("#{app_dir}/config/database.yml")[rails_env]) | ||
end | end | ||
</nowiki>}} | </nowiki>}} | ||
Line 663: | Line 532: | ||
{{hc|/etc/nginx/conf.d/booru.eikonos.org.conf|<nowiki>upstream app { | {{hc|/etc/nginx/conf.d/booru.eikonos.org.conf|<nowiki>upstream app { | ||
# Path to Puma SOCK file, as defined previously | # Path to Puma SOCK file, as defined previously | ||
server unix:/ | server unix:/home/moe/booru/shared/sockets/puma.sock fail_timeout=0; | ||
} | } | ||
Line 681: | Line 550: | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | proxy_set_header X-Forwarded-Proto $scheme; | ||
# Fix the | # Fix the "It appears that your reverse proxy set up is broken" error. | ||
proxy_pass http://app; | proxy_pass http://app; | ||
proxy_read_timeout 90; | proxy_read_timeout 90; | ||
Line 695: | Line 564: | ||
{{bc|bundle exec puma -C shared/puma.rb}} | {{bc|bundle exec puma -C shared/puma.rb}} | ||
== Systemd Service == | == Systemd Service == | ||
Line 862: | Line 674: | ||
}} | }} | ||
Images | Images only: | ||
{{bc| | {{bc| | ||
tar -cvzf eikonos.org- | tar -cvzf eikonos.org-20170128_images.tar.gz /var/www/moebooru/public/data/image/ | ||
}} | }} | ||
Code only, no binaries | Code only, no binaries: | ||
{{bc|<nowiki> | {{bc|<nowiki> | ||
tar --exclude='/home/moe/booru/tmp | tar --exclude='/home/moe/booru/tmp' --exclude='/home/moe/booru/vendor' -cvjf eikonos.org-20170128_var_www_booru-eikonos-org.tar.gz /home/moe/booru | ||
</nowiki>}} | </nowiki>}} | ||
== Sources == | == Sources == | ||
* Get configuration tips from here: http://wiki.douglasqsantos.com.br/doku.php/deploying_a_rails_app_on_debian_jessie_with_capistrano_nginx_and_puma_en | * Get configuration tips from here: http://wiki.douglasqsantos.com.br/doku.php/deploying_a_rails_app_on_debian_jessie_with_capistrano_nginx_and_puma_en |