Created
March 31, 2020 14:37
-
-
Save Deanout/17bd141858553030379e070a68aa827a to your computer and use it in GitHub Desktop.
Deploy to production with nginx, passenger, capistrano, rails 6
This file contains 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
These commands are meant to be followed in conjunction with: | |
https://www.youtube.com/watch?v=xpYpaRUFzTI | |
https://gorails.com/deploy/ubuntu/18.04 | |
ssh [email protected] | |
adduser deploy | |
adduser deploy sudo | |
exit | |
ssh-copy-id [email protected] | |
ssh-copy-id [email protected] | |
ssh [email protected] | |
# Adding Node.js 10 repository | |
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - | |
# Adding Yarn repository | |
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 add-apt-repository ppa:chris-lea/redis-server | |
# Refresh our packages list with the new repositories | |
sudo apt-get update | |
# Install our dependencies for compiiling Ruby along with Node.js and Yarn | |
sudo apt-get install git-core curl 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 dirmngr gnupg apt-transport-https ca-certificates redis-server redis-tools nodejs yarn | |
git clone https://github.com/rbenv/rbenv.git ~/.rbenv | |
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc | |
echo 'eval "$(rbenv init -)"' >> ~/.bashrc | |
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build | |
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc | |
git clone https://github.com/rbenv/rbenv-vars.git ~/.rbenv/plugins/rbenv-vars | |
exec $SHELL | |
rbenv install 2.7.0 | |
rbenv global 2.7.0 | |
ruby -v | |
# This installs the latest Bundler, currently 2.x. | |
gem install bundler | |
# For older apps that require Bundler 1.x, you can install it as well. | |
gem install bundler -v 1.17.3 | |
# Test and make sure bundler is installed correctly, you should see a version number. | |
bundle -v | |
# Bundler version 2.0 | |
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7 | |
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger bionic main > /etc/apt/sources.list.d/passenger.list' | |
sudo apt-get update | |
sudo apt-get install -y nginx-extras libnginx-mod-http-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 | |
sudo ls /etc/nginx/conf.d/mod-http-passenger.conf | |
# If you want to use the Nano for editing | |
sudo nano /etc/nginx/conf.d/mod-http-passenger.conf | |
# If you want to use the Vim for editing | |
sudo vim /etc/nginx/conf.d/mod-http-passenger.conf | |
sudo service nginx start | |
sudo rm /etc/nginx/sites-enabled/default | |
# If you want to use the Nano for editing | |
sudo nano /etc/nginx/sites-enabled/myapp | |
# If you want to use the Vim for editing | |
sudo vim /etc/nginx/sites-enabled/myapp | |
## SETUP YOUR NGINX CONF | |
sudo service nginx reload | |
sudo apt-get install postgresql postgresql-contrib libpq-dev | |
sudo su - postgres | |
createuser --pwprompt deploy | |
createdb -O deploy myapp | |
exit | |
bundle | |
cap install STAGES=production | |
## Setup Capfile, Config/deploy.rb, config/deploy/production.rb | |
ssh [email protected] | |
mkdir /home/deploy/myapp | |
nano /home/deploy/myapp/.rbenv-vars | |
##Setup environment variables | |
cap production deploy | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment