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.


Then, initialize and start the database.
Now log in and create the moebooru database and user: (make sure to create a very good password!)
 
{{bc|
# /usr/pgsql-9.6/bin/postgresql96-setup initdb
# systemctl start postgresql-9.6
}}
 
Now log in and create the moebooru database and user with createdb permissions: (make sure to give it a very good password!)


{{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 # CREATE USER moebooru_user WITH PASSWORD 'your_password' CREATEDB;
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, which can be fiendishly difficult.
''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.
 
{{Warning|If you can't get Rubinius to work or to compile your gems, don't waste your time on it anymore. Just use standard Ruby 2.3.}}


=== Method 1: Set up Normal Ruby 2.3 or newer ===
=== Method 1: Set up Normal Ruby 2.3 or newer ===
Line 119: Line 109:
* 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: Installing Rubinius Binaries with chruby ===
=== Method 2: Install Rubinius with RVM ===


{{hc|Debian/Ubuntu|
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.
sudo apt-get install openssl libreadline6 libreadline6-dev \
curl zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 \
libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev libtool  \
pkg-config libgdbm-dev ncurses-dev libffi-dev
}}
 
{{hc|Red Hat/CentOS|
sudo yum install ruby
sudo yum install -y patch autoconf libtool sqlite-devel
}}
 
Rubinius is particularly tough to compile, and as of 2017-01-28 we have not been able to compile it with Debian Jessie. Instead, [https://rubinius.com/install/ Rubinius provides Ubuntu 14.04 binaries designed for use with Travis-Cl.]


First, download and install [https://github.com/postmodern/chruby chruby] as a user with sudo privileges.
==== Dependencies (Debian/Ubuntu) ====


{{bc|
{{bc|
wget -O chruby-0.3.9.tar.gz https://github.com/postmodern/chruby/archive/v0.3.9.tar.gz
sudo apt-get install ruby
tar -xzvf chruby-0.3.9.tar.gz
sudo apt-get install build-essential openssl libreadline6 libreadline6-dev \
cd chruby-0.3.9/
curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 \
sudo make install
libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison  \
subversion pkg-config libgdbm-dev ncurses-dev libffi-dev
}}
}}


Next, log in as the {{ic|moe}} user, download the latest rubinius binaries, and extract them to {{ic|/home/moe/}}:
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|
sudo -i -u moe
# if on debian jessie, set up jessie-backports: https://backports.debian.org/Instructions/
wget -O rubinius-3.70.tar.bz2 https://rubinius-binaries-rubinius-com.s3.amazonaws.com/ubuntu/14.04/x86_64/rubinius-3.70.tar.bz2
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 libedit2 libedit-dev
tar -xjvf rubinius-3.70.tar.bz2
}}
}}


Then, activate chruby with rubinius by adding it to the bashrc.
<div class="toccolours mw-collapsible mw-collapsed" style="width:53em">
 
Click '''Expand''' to display the {{ic|update-alternatives}} commands, which activate 3.8 as the default clang/llvm version.
{{hc|/home/moe/.bashrc|<nowiki>
<div class="mw-collapsible-content">
source /usr/local/share/chruby/chruby.sh
 
RUBIES+=(
  "$HOME/rubinius/3.70"
)
</nowiki>}}
 
Finally, log out and log back into the {{ic|moe}} user, and set rubinius 3.70 as the default ruby version.
 
{{bc|
{{bc|
chruby 3.70
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.8 100
}}
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.8 100
 
sudo update-alternatives --install \
=== Method 3: Install Rubinius with RVM ===
        /usr/bin/llvm-config      llvm-config      /usr/bin/llvm-config-3.8  200 \
 
--slave /usr/bin/llvm-ar          llvm-ar          /usr/bin/llvm-ar-3.8 \
{{Note|Unfortunately, until the [https://github.com/jruby/activerecord-jdbc-adapter/issues/708 ActiveRecord-JDBC-Adapter] required by JRuby is ported to Rails 5, we can't use it with Moebooru.}}
--slave /usr/bin/llvm-as          llvm-as          /usr/bin/llvm-as-3.8 \
 
--slave /usr/bin/llvm-bcanalyzer  llvm-bcanalyzer  /usr/bin/llvm-bcanalyzer-3.8 \
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.
--slave /usr/bin/llvm-cov          llvm-cov        /usr/bin/llvm-cov-3.8 \
--slave /usr/bin/llvm-diff        llvm-diff        /usr/bin/llvm-diff-3.8 \
--slave /usr/bin/llvm-dis          llvm-dis        /usr/bin/llvm-dis-3.8 \
--slave /usr/bin/llvm-dwarfdump    llvm-dwarfdump  /usr/bin/llvm-dwarfdump-3.8 \
--slave /usr/bin/llvm-extract      llvm-extract    /usr/bin/llvm-extract-3.8 \
--slave /usr/bin/llvm-link        llvm-link        /usr/bin/llvm-link-3.8 \
--slave /usr/bin/llvm-mc          llvm-mc          /usr/bin/llvm-mc-3.8 \
--slave /usr/bin/llvm-mcmarkup    llvm-mcmarkup    /usr/bin/llvm-mcmarkup-3.8 \
--slave /usr/bin/llvm-nm          llvm-nm          /usr/bin/llvm-nm-3.8 \
--slave /usr/bin/llvm-objdump      llvm-objdump    /usr/bin/llvm-objdump-3.8 \
--slave /usr/bin/llvm-ranlib      llvm-ranlib      /usr/bin/llvm-ranlib-3.8 \
--slave /usr/bin/llvm-readobj      llvm-readobj    /usr/bin/llvm-readobj-3.8 \
--slave /usr/bin/llvm-rtdyld      llvm-rtdyld      /usr/bin/llvm-rtdyld-3.8 \
--slave /usr/bin/llvm-size        llvm-size        /usr/bin/llvm-size-3.8 \
--slave /usr/bin/llvm-stress      llvm-stress      /usr/bin/llvm-stress-3.8 \
--slave /usr/bin/llvm-symbolizer  llvm-symbolizer  /usr/bin/llvm-symbolizer-3.8 \
--slave /usr/bin/llvm-tblgen      llvm-tblgen      /usr/bin/llvm-tblgen-3.8
|lang=bash}}
[https://gist.github.com/jc00ke/b55cf7d16d584fbb2b92 Source: Github Gist - LLVM-Update-Alternatives]
</div></div>


==== Installation with RVM (RHEL/CentOS) ====
==== Dependencies (RHEL/CentOS) ====
 
{{Note|Frustratingly, Rubinius refuses to build with Debian Jessie for some darn reason, so this is for RHEL/CentOS only.}}


{{bc|
{{bc|
sudo yum install ruby
sudo yum install ruby
sudo yum install -y patch autoconf patch automake libtool bison sqlite-devel bzip2 zlib-devel libyaml-devel readline-devel openssl-devel
sudo yum install -y patch autoconf patch automake libtool bison sqlite-devel
}}
}}


Line 204: Line 190:
}}
}}


{{Note|Make sure to run all these steps as the {{ic|moe}} user.}}
==== Using RVM ====


[https://rvm.io/ Follow the RVM installation instructions, as replicated below:]
{{Note|Make sure to run all these steps as the moebooru user.}}
 
First, ''as the {{ic|moe}} user,'' [https://rvm.io/ follow the RVM installation instructions, as replicated below:]


{{bc|<nowiki>
{{bc|<nowiki>
Line 261: Line 249:


{{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.}}
<!--
<!--
==== Installation (Debian/Ubuntu) ====
{{bc|
sudo apt-get install ruby ruby-dev
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 pkg-config libgdbm-dev ncurses-dev libffi-dev
}}
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|
# 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 libedit2 libedit-dev
}}
<div class="toccolours mw-collapsible mw-collapsed" style="width:53em">
Click '''Expand''' to display the {{ic|update-alternatives}} commands, which activate 3.8 as the default clang/llvm version.
<div class="mw-collapsible-content">
{{bc|
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.8 100
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.8 100
sudo update-alternatives --install \
        /usr/bin/llvm-config      llvm-config      /usr/bin/llvm-config-3.8  200 \
--slave /usr/bin/llvm-ar          llvm-ar          /usr/bin/llvm-ar-3.8 \
--slave /usr/bin/llvm-as          llvm-as          /usr/bin/llvm-as-3.8 \
--slave /usr/bin/llvm-bcanalyzer  llvm-bcanalyzer  /usr/bin/llvm-bcanalyzer-3.8 \
--slave /usr/bin/llvm-cov          llvm-cov        /usr/bin/llvm-cov-3.8 \
--slave /usr/bin/llvm-diff        llvm-diff        /usr/bin/llvm-diff-3.8 \
--slave /usr/bin/llvm-dis          llvm-dis        /usr/bin/llvm-dis-3.8 \
--slave /usr/bin/llvm-dwarfdump    llvm-dwarfdump  /usr/bin/llvm-dwarfdump-3.8 \
--slave /usr/bin/llvm-extract      llvm-extract    /usr/bin/llvm-extract-3.8 \
--slave /usr/bin/llvm-link        llvm-link        /usr/bin/llvm-link-3.8 \
--slave /usr/bin/llvm-mc          llvm-mc          /usr/bin/llvm-mc-3.8 \
--slave /usr/bin/llvm-mcmarkup    llvm-mcmarkup    /usr/bin/llvm-mcmarkup-3.8 \
--slave /usr/bin/llvm-nm          llvm-nm          /usr/bin/llvm-nm-3.8 \
--slave /usr/bin/llvm-objdump      llvm-objdump    /usr/bin/llvm-objdump-3.8 \
--slave /usr/bin/llvm-ranlib      llvm-ranlib      /usr/bin/llvm-ranlib-3.8 \
--slave /usr/bin/llvm-readobj      llvm-readobj    /usr/bin/llvm-readobj-3.8 \
--slave /usr/bin/llvm-rtdyld      llvm-rtdyld      /usr/bin/llvm-rtdyld-3.8 \
--slave /usr/bin/llvm-size        llvm-size        /usr/bin/llvm-size-3.8 \
--slave /usr/bin/llvm-stress      llvm-stress      /usr/bin/llvm-stress-3.8 \
--slave /usr/bin/llvm-symbolizer  llvm-symbolizer  /usr/bin/llvm-symbolizer-3.8 \
--slave /usr/bin/llvm-tblgen      llvm-tblgen      /usr/bin/llvm-tblgen-3.8
|lang=bash}}
[https://gist.github.com/jc00ke/b55cf7d16d584fbb2b92 Source: Github Gist - LLVM-Update-Alternatives]
</div></div>
==== Setup Rubinius with Zonio Repo (RHEL/CentOS) ====
==== Setup Rubinius with Zonio Repo (RHEL/CentOS) ====


Line 352: Line 290:
https://zonio.net/rubinius_rpm_packages/
https://zonio.net/rubinius_rpm_packages/
-->
-->
{{Note|If you encounter any issues with gems that say "Ignoring because extensions are not built", run {{ic|gem pristine --all}}}}


== Mandatory Access Control ==
== Mandatory Access Control ==
Line 360: Line 296:


anyone have apparmor profiles?
anyone have apparmor profiles?
We may have to create our own through learning mode: http://www.howtogeek.com/118328/how-to-create-apparmor-profiles-to-lock-down-programs-on-ubuntu/


=== SELinux Permissions (RHEL/CentOS) ===
=== SELinux Permissions (RHEL/CentOS) ===
Line 417: Line 351:
=== Configure Moebooru ===
=== Configure Moebooru ===


All commands in this section must be run as the {{ic|moe}} user:
First, [http://stackoverflow.com/a/9235107 do a bundle config for pg] since we're using a specific postgresql version:


{{bc|sudo -i -u moe}}
{{bc|<nowiki>bundle config build.pg --with-pg-config=/usr/pgsql-9.6/bin/pg_config</nowiki>}}


First, [http://stackoverflow.com/a/9235107 do a bundle config for pg] since we're using a specific postgresql version:
Generate your secret key, which is used for salts and such.


{{bc|<nowiki>
{{bc|bundle exec rake secret}}
bundle config build.pg --with-pg-config=/usr/pgsql-9.6/bin/pg_config    # Red Hat/CentOS Only
bundle config build.pg --with-pg-config=/usr/bin/pg_config              # Debian Only
</nowiki>}}


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 366:


{{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
}}
}}
Generate your secret key, which is used for salts and such.
{{bc|bundle exec rake secret}}


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 396:
{{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 with {{ic|ERROR:  must be owner of extension plpgsql}} which is normal, proceed)
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|If you have trouble creating databases because they set to SQL_ASCII by default, [https://gist.github.com/amolkhanorkar/8706915 follow this guide to require UTF-8 to be set by default.] }}


{{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 410:
{{bc|chmod 755 /home/moe/booru/public}}
{{bc|chmod 755 /home/moe/booru/public}}


Start the server: {{ic|bundle exec unicorn}} or {{ic|bundle exec puma}} if using Rubinius. Note that this will start the server in '''development mode''', which is somewhat slower. See the Production Mode section once you are ready to serve the site.
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 520:
=== Run the Server ===
=== Run the Server ===


Finally, to run the server at, for example, port 9292, run one of the following commands:
Finally, to run the server (default is port 9292), run one of the following commands:


Ruby:
Ruby:
Line 603: Line 528:
Rubinius:
Rubinius:


{{bc|<nowiki>RAILS_ENV=production bundle exec puma -e production -p 9292</nowiki>}}
{{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 539:


<pre>grep -c processor /proc/cpuinfo</pre>
<pre>grep -c processor /proc/cpuinfo</pre>
Create the following folders in your application directory:


Create a folder to store your UNIX sockets and PIDs in:
<pre>mkdir -p shared/pids shared/sockets shared/log</pre>
 
{{bc|
sudo mkdir /var/run/moebooru
sudo chown -R moe:moe /var/run/moebooru
}}
 
Create the following folders in your application directory to store logs:
 
<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 550:
threads 1, 6
threads 1, 6


app_dir = File.expand_path("../..", __FILE__)
app_dir = File.expand_path(&quot;../..&quot;, __FILE__)
shared_dir = "#{app_dir}/shared"
shared_dir = &quot;#{app_dir}/shared&quot;
socket_dir = "/var/run/moebooru"


# Default to production
# Default to production
rails_env = ENV['RAILS_ENV'] || "production"
rails_env = ENV['RAILS_ENV'] || &quot;production&quot;
environment rails_env
environment rails_env


# Set up socket location
# Set up socket location
bind "unix://#{socket_dir}/puma.sock"
bind &quot;unix://#{shared_dir}/sockets/puma.sock&quot;


# Logging
# Logging
stdout_redirect "#{shared_dir}/log/puma.stdout.log", "#{shared_dir}/log/puma.stderr.log", true
stdout_redirect &quot;#{shared_dir}/log/puma.stdout.log&quot;, &quot;#{shared_dir}/log/puma.stderr.log&quot;, true


# Set master PID and state locations
# Set master PID and state locations
pidfile "#{socket_dir}/puma.pid"
pidfile &quot;#{shared_dir}/pids/puma.pid&quot;
state_path "#{socket_dir}/puma.state"
state_path &quot;#{shared_dir}/pids/puma.state&quot;
activate_control_app
activate_control_app


on_worker_boot do
on_worker_boot do
   require "active_record"
   require &quot;active_record&quot;
   ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished
   ActiveRecord::Base.connection.disconnect! rescue ActiveRecord::ConnectionNotEstablished
   ActiveRecord::Base.establish_connection(YAML.load_file("#{app_dir}/config/database.yml")[rails_env])
   ActiveRecord::Base.establish_connection(YAML.load_file(&quot;#{app_dir}/config/database.yml&quot;)[rails_env])
end
end
</nowiki>}}
</nowiki>}}
Line 663: Line 579:
{{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:/var/run/moebooru/puma.sock fail_timeout=0;
     server unix:/home/moe/booru/shared/sockets/puma.sock fail_timeout=0;
}
}


Line 681: Line 597:
       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 "It appears that your reverse proxy set up is broken" error.
       # Fix the &quot;It appears that your reverse proxy set up is broken&quot; error.
       proxy_pass http://app;
       proxy_pass http://app;
       proxy_read_timeout 90;
       proxy_read_timeout 90;
Line 695: Line 611:


{{bc|bundle exec puma -C shared/puma.rb}}
{{bc|bundle exec puma -C shared/puma.rb}}
== Separate subdomain for images and static content ==
It's often a better idea to have static content served from another subdomain entirely, where it will be cached for much longer than ever changing text. And sometimes the files could be located on an entirely different server.
Edit your {{ic|config/local_config.rb}} to activate the {{ic|assets.}} and {{ic|files.}} subdomains.
{{hc|config/local_config.rb|<nowiki>
# Servers for static files (assets and uploaded files)
CONFIG[:file_hosts] = { :files => "files.eikonos.org", :assets => "assets.eikonos.org" }
</nowiki>}}
Then, create these two nginx configs (customize the server_name to your subdomains, must start with {{ic|assets.}} and {{ic|files.}}):
{{hc|/etc/nginx/conf.d/moebooru_assets.conf|<nowiki>server {
    listen 127.0.0.1:8080; # tells Nginx to listen for traffic passed by Varnish if unencrypted http
    server_name assets.eikonos.org;
    # directory of static assets, first generate with the command:
    # RAILS_ENV=production bundle exec rake assets:precompile
    root /home/moe/booru/public;
    error_page 500 502 503 504 /500.html;
    keepalive_timeout 10;
    location ^~ / {
        expires 1M;
        access_log off;
        add_header Cache-Control "public";
        try_files $uri =404;
    }
    # users must access files.eikonos.org for full images, though thumbs are shared through assets
    location ^~ /data/images/ { deny all; }
}
</nowiki>}}
{{hc|/etc/nginx/conf.d/moebooru_files.conf|<nowiki>
server {
    listen 127.0.0.1:8080; # tells Nginx to listen for traffic passed by Varnish if unencrypted http
    server_name files.eikonos.org;
    # directory of full size files
    root /home/moe/booru/public/;
    error_page 500 502 503 504 /500.html;
    keepalive_timeout 10;
    location ^~ /data/ {
        expires 1M;
        access_log off;
        add_header Cache-Control "public";
        try_files $uri =404;
    }
    location ^~ /assets/ { deny all; } # users must access assets.eikonos.org for this
}
</nowiki>}}


== Systemd Service ==
== Systemd Service ==
Line 862: Line 721:
}}
}}


Images and thumbs and other generated items:
Images only:


{{bc|
{{bc|
tar -cvzf eikonos.org-20170128_data.tar.gz /var/www/moebooru/public/data/
tar -cvzf eikonos.org-20170128_images.tar.gz /var/www/moebooru/public/data/image/
}}
}}


Code only, no binaries or image data:
Code only, no binaries:


{{bc|<nowiki>
{{bc|<nowiki>
tar --exclude='/home/moe/booru/tmp' --exclude='/home/moe/booru/public' --exclude='/home/moe/booru/vendor' -cvjf eikonos.org-20170128_var_www_booru-eikonos-org.tar.gz /home/moe/booru
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>}}
== Restore/Move ==
=== PostgreSQL database ===
First, create the user with CreateDB permissions:
{{bc|
# su - postgres
$ psql
postgres # CREATE USER moebooru_user CREATEDB;
}}
then import the sql dump with that user.
== Troubleshooting ==
=== Pagination not showing in Post#index ===
{{Note|This issue only occurs when you are using the default cache instead of Memcached. We strongly recommend using Memcached for this reason.}}
https://github.com/moebooru/moebooru/issues/42
=== Atom RSS Canonical URL Problem ===
Bloo had met an issue with the [https://github.com/moebooru/moebooru/issues/71 Atom RSS URLs pointing to his IP instead of the domain name.] Here's the patch he used:
{{bc|
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -126,7 +126,7 @@ module ApplicationHelper
    elsif post.is_a?(Array)
      posts = post
-      new_params = params.to_unsafe_h.merge :only_path => true
+      new_params = params.to_unsafe_h.merge :host=>'otakupaper.com'
      if posts.previous_page.present?
        html << tag("link", :href => url_for(new_params.merge :page => 1), :rel => "first", :title => "First Page")
diff --git a/app/helpers/post_helper.rb b/app/helpers/post_helper.rb
index 32cf04f..cf98cb5 100644
--- a/app/helpers/post_helper.rb
+++ b/app/helpers/post_helper.rb
@@ -18,7 +18,7 @@ module PostHelper
      "type"  => tag_options[:type] || "application/#{type}+xml",
      "title" => tag_options[:title] || type.to_s.upcase,
      "id"    => tag_options[:id],
-      "href"  => url_options.is_a?(Hash) ? url_for(url_options.merge(:only_path => false)) : url_options
+      "href"  => url_options.is_a?(Hash) ? url_for(url_options.merge(:host => CONFIG["server_host"])) : url_options
    )
  end
}}


== 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
Please note that all contributions to Bibliotheca Anonoma are considered to be released under the Creative Commons Attribution-ShareAlike (see Bibliotheca Anonoma:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)

Templates used on this page: