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 62: | Line 62: | ||
{{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 database and user: (make sure to create a very good password!) | |||
Now log in and create the moebooru database and user | |||
{{bc|$ sudo su # becoming the postgres user doesn't really work with sudo for some reason | {{bc|$ sudo su # becoming the postgres user doesn't really work with sudo for some reason | ||
# su - postgres | # su - postgres | ||
$ psql | $ psql | ||
postgres # | postgres # create user moebooru_user with password 'your_password' createdb;}} | ||
}} | |||
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 100: | ||
''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 121: | Line 111: | ||
=== Method 2: Installing Rubinius Binaries with chruby === | === Method 2: Installing Rubinius Binaries with chruby === | ||
https://github.com/postmodern/chruby | |||
Download the latest rubinius binaries and extract them to {{ic|/home/moe/}}. | |||
https://rubinius.com/install/ | |||
=== Method 3: Install Rubinius with RVM === | === Method 3: Install Rubinius with RVM === | ||
Line 180: | Line 129: | ||
{{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 352: | Line 301: | ||
https://zonio.net/rubinius_rpm_packages/ | https://zonio.net/rubinius_rpm_packages/ | ||
--> | --> | ||
== Mandatory Access Control == | == Mandatory Access Control == | ||
Line 431: | Line 378: | ||
{{bc|bundle install --path vendor/bundle}} | {{bc|bundle install --path vendor/bundle}} | ||
Generate your secret key, which is used for salts and such. | |||
{{bc|bundle exec rake secret}} | |||
Obtain <code>config/database.yml</code> and <code>config/local_config.rb</code> from the <code>.example</code> files, and configure them accordingly. Then set <code>chmod 700</code> so only the moebooru user can read the database password. | Obtain <code>config/database.yml</code> and <code>config/local_config.rb</code> from the <code>.example</code> files, and configure them accordingly. Then set <code>chmod 700</code> so only the moebooru user can read the database password. | ||
Line 440: | Line 391: | ||
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 416: | ||
{{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 430: | ||
{{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 540: | ||
=== 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 548: | ||
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 559: | ||
<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 570: | ||
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 599: | ||
{{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 617: | ||
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 631: | ||
{{bc|bundle exec puma -C shared/puma.rb}} | {{bc|bundle exec puma -C shared/puma.rb}} | ||
== Systemd Service == | == Systemd Service == | ||
Line 862: | Line 741: | ||
}} | }} | ||
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 |