Last active
September 11, 2024 16:04
-
-
Save cerico/1d9ba5f18612ae3a1e27a6db75ddaad9 to your computer and use it in GitHub Desktop.
pm2 rails nginx setup
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
#!/bin/bash | |
###--- Basics ---### | |
sudo apt-get update | |
sudo apt-get install -y tree software-properties-common git-core openssl libssl-dev git vim curl zsh | |
###--- Node ---### | |
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - | |
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5 | |
echo "deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.6 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list | |
###--- Elixir ---### | |
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && sudo dpkg -i erlang-solutions_1.0_all.deb | |
###--- Docker ---### | |
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - | |
sudo apt-add-repository "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") $(lsb_release -cs) stable" | |
sudo apt-get update | |
###--- Main Installs ---### | |
sudo apt-get install mongodb-org python3-setuptools default-jre libreadline-dev inotify-tools esl-erlang elixir nodejs docker-ce build-essential apt-transport-https ca-certificates gnupg2 autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev git-core libpq-dev postgresql postgresql-client -y | |
###--- zsh ---### | |
if [ ! -d ~/.oh-my-zsh ]; then | |
sh -c "$(curl -fsSL https://raw.githubusercontent.com/cerico/dotfiles/master/zfiles/oh-my-zsh/scripted-install.sh)" | |
exit | |
fi | |
###--- Rails & Ruby ---### | |
git clone https://github.com/rbenv/rbenv.git ~/.rbenv | |
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build | |
export PATH="$HOME/.rbenv/bin:$PATH" && rbenv install 2.4.3 | |
rbenv global 2.4.3 | |
echo "gem: --no-document" > ~/.gemrc | |
~/.rbenv/shims/gem install bundler | |
~/.rbenv/shims/gem install rails | |
###--- Postgres ---### | |
sudo -u postgres createuser root -s | |
sudo su postgres -c "psql -c \"CREATE ROLE root SUPERUSER LOGIN PASSWORD 'root'\" " | |
sudo su postgres -c "createdb -E UTF8 -T template0 --locale=en_US.utf8 -O root root" | |
###--- Docker Compose ---### | |
sudo curl -L https://github.com/docker/compose/releases/download/1.17.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
###--- Nginx ---### | |
gpg --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7 | |
gpg --armor --export 561F9B9CAC40B2F7 | sudo apt-key add - | |
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger jessie main > /etc/apt/sources.list.d/passenger.list' | |
sudo apt-get update | |
sudo apt-get install -y nginx-extras passenger | |
npm install pm2 -g | |
cd /opt | |
wget https://dl.eff.org/certbot-auto | |
chmod a+x certbot-auto | |
cd /root | |
wget https://gist.githubusercontent.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/81840effe34c42270e475f0084a05562cbcd30f2/create-sample-rails.sh | |
curl https://gist.githubusercontent.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/efba4f61fdb615453629636cfb442c1eee6038a9/rails.conf > /etc/nginx/conf.d/hello-rails.conf | |
git clone https://github.com/cerico/dotfiles.git | |
if [ ~/dotfiles ]; then | |
touch ~/dotfiles/zfiles/rfy | |
touch ~/.zshrc.local | |
ln -s ~/dotfiles/.zshrc ~/.zshrc | |
ln -s ~/dotfiles/.zprofile ~/.zprofile | |
ln -s ~/dotfiles/zfiles ~/zfiles | |
fi |
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
#!/bin/bash | |
rails new hello-rails --database=postgresql && cd hello-rails | |
bundle install | |
bundle exec rake db:create | |
bundle exec rake db:migrate | |
wget https://gist.githubusercontent.com/cerico/1d9ba5f18612ae3a1e27a6db75ddaad9/raw/5559fc1488145275454078324339432c1bf467a2/run.sh |
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
server { | |
if ($host = hello-rails.io37.cc) { | |
return 301 https://$host$request_uri; | |
} # managed by Certbot | |
listen 80; | |
server_name hello-rails.io37.cc; | |
return 301 https://$host$request_uri; | |
} | |
server { | |
listen 443 ssl; | |
server_name hello-rails.io37.cc; | |
location / { | |
proxy_pass http://localhost:54000; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection 'upgrade'; | |
proxy_set_header Host $host; | |
proxy_cache_bypass $http_upgrade; | |
} | |
} |
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
#!/bin/bash | |
pm2 start 'rails s -p 54000 -b 0.0.0.0' --name "$(basename `pwd`)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment