-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy_rails_tutorial
75 lines (59 loc) · 2.15 KB
/
deploy_rails_tutorial
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Install rbenv + ruby
https://gorails.com/setup/ubuntu/20.04
sudo apt install curl
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn
cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
rbenv install 3.0.1
rbenv global 3.0.1
ruby -v
gem install bundler
gem install rails -v 6.1.3.1
rbenv rehash
### Setting Up A Database
1. Mysql
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
2. PostgreSQL
sudo apt install postgresql libpq-dev
sudo -u postgres createuser chris -s
# If you would like to set a password for the user, you can do the following
sudo -u postgres psql
postgres=# \password chris
# create database
CREATE DATABASE lusiadas;
# puma_test_app_staging.service
[Unit]
Description=Puma HTTP Server for test_app (staging)
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/var/www/test_app/current
ExecStart=/root/.rbenv/bin/rbenv exec bundle exec puma -C /var/www/test_app/shared/puma.rb
ExecReload=/bin/kill -TSTP $MAINPID
StandardOutput=append:/var/www/test_app/shared/log/puma_access.log
StandardError=append:/var/www/test_app/shared/log/puma_error.log
Restart=always
RestartSec=1
SyslogIdentifier=puma
[Install]
WantedBy=multi-user.target
# Sidekiq with systemd
Run sidekiq with systemd
# deploy rails
# /etc/systemd/system
# sudo systemctl daemon-reload
# systemctl enable sidekiq
# systemctl start sidekiq
# systemctl status sidekiq.service
https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04