Last active
June 1, 2021 12:59
-
-
Save samgooi4189/2951761aecbdcbcca60e63973ef0bd74 to your computer and use it in GitHub Desktop.
ruby workshop 20210601 cheat sheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# clone and cd into your repo | |
create config/master.key | |
38e8eded99cab7f153507c62c5093659 | |
# Add non-root user | |
useradd --create-home --shell /bin/bash deploy | |
sudo usermod -aG sudo deploy | |
sudo echo "ALL ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers | |
su deploy | |
cd | |
ssh-keygen | |
touch .ssh/authorized_keys | |
sudo cat /root/.ssh/authorized_keys > .ssh/authorized_keys | |
exit | |
now you can ssh with deploy@[ip] | |
# Install dependencies | |
sudo apt-get install -y git build-essential libpq-dev nodejs npm -y | |
sudo npm install -g yarn | |
gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB | |
curl -L https://get.rvm.io | bash -s stable | |
bash -l | |
rvm install 3.0 | |
# install passenger | |
sudo su | |
apt-get install -y dirmngr gnupg nginx | |
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7 | |
apt-get install -y apt-transport-https ca-certificates | |
echo deb https://oss-binaries.phusionpassenger.com/apt/passenger $(lsb_release -cs) main > /etc/apt/sources.list.d/passenger.list | |
apt-get update | |
apt-get install -y libnginx-mod-http-passenger | |
# enable passenger | |
if [ ! -f /etc/nginx/modules-enabled/50-mod-http-passenger.conf ]; then sudo ln -s /usr/share/nginx/modules-available/mod-http-passenger.load /etc/nginx/modules-enabled/50-mod-http-passenger.conf ; fi | |
ls /etc/nginx/conf.d/mod-http-passenger.conf | |
service nginx restart | |
/usr/bin/passenger-config validate-install | |
# configure nginx | |
sudo su deploy | |
bash -l | |
passenger-config about ruby-command | |
exit # to deploy user | |
exit # to root user | |
vim /etc/nginx/sites-enabled/myapp.conf | |
# content of nginx config | |
server { | |
listen 80; | |
server_name [your vm IP]; | |
# Tell Nginx and Passenger where your app's 'public' directory is | |
root /home/deploy/app/current/public; | |
# Turn on Passenger | |
passenger_enabled on; | |
passenger_ruby /home/deploy/.rvm/gems/ruby-3.0.0/wrappers/ruby; | |
} | |
# try your website | |
service nginx restart | |
curl [IP address] | |
visit your website with [IP address] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment