Coder Social home page Coder Social logo

gallery's Introduction

Gallery on Rails: Setup ->

Ruby version

  • 2.4.1

System dependencies

  • RVM
  • ImageMagick
  • Postgresql
  • Redis
  • Nginx

Configuration

  1. Create .bashrc file in nginx's home folder where save next variables (You can generate random value with command rake secret):
[[ -s /usr/local/rvm/scripts/rvm ]] && source /usr/local/rvm/scripts/rvm

  1. Create .profile file in nginx's user home folder and put this code:
if [ -n "$BASH_VERSION" ]; then
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi
  1. Copy config/secrets.yml.example to config/secrets.yml and put new secret phrase:
production:
  secret_key_base: HARD_PASSWORD

Database creation

Before next step make copy file database.yml.example to database.yml and write your settings. Execute sudo -u postgres psql and enter next commands:

CREATE ROLE gallery WITH PASSWORD 'your_strong_password';
CREATE DATABASE gallery TEMPLATE template0 ENCODING 'UNICODE';
ALTER DATABASE gallery OWNER TO gallery;
GRANT ALL PRIVILEGES ON DATABASE gallery TO gallery;
ALTER ROLE gallery WITH LOGIN;
\connect gallery
CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;

Config for nginx

server {
    server_name server.com;
    listen 80;
    listen [::]:80;

    return 301 https://$host$request_uri;
}

server {
    server_name server.com;
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    ssl_certificate /etc/letsencrypt/live/server.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/server.com/privkey.pem;
    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:50m;
    ssl_session_tickets off;

    ssl_protocols TLSv1.2;
    ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
    ssl_prefer_server_ciphers on;

    add_header Strict-Transport-Security max-age=15768000;
    add_header X-Content-Type-Options nosniff;
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Robots-Tag none;
    add_header X-Download-Options noopen;
    add_header X-Permitted-Cross-Domain-Policies none;

    ssl_stapling on;
    ssl_stapling_verify on;
    ssl_trusted_certificate /etc/letsencrypt/live/server.com/chain.pem;
    resolver 8.8.8.8;

    root /var/www/gallery/public;

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location ~* \.(?:png|ico|jpg|jpeg|ttf|svg|eot|woff|woff2)$ {
        try_files $uri /index.php$uri$is_args$args;
        access_log off;
    }

    client_max_body_size 512M;

    passenger_enabled on;
}

Deployment instructions

Edit deployment config (config/deploy.rb) and execute command:

cap production deploy

Creating admin

On production server enter in directory with current version of application (e.g. /www/server.com/current) under user nginx and execute next commands:

RAILS_ENV=production rails console
#then console initialized:
Admin.new(email: '[email protected]', password: 'MakeH@rdpasswd').save
exit

gallery's People

Contributors

sameignatovich avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.