sudo apt-get update && sudo apt-get upgrade -y
timedatectl set-local-rtc 1 --adjust-system-clock
List of software that will be installed:
- Google Chrome Beta:
- Sublime Text
- Filezilla
- Gnome Tweak
- Multimedia Codecs
- Ubuntu Cleaner
- Rar, p7zip
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list
sudo apt update
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
sudo apt install apt-transport-https
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt update
sudo add-apt-repository ppa:gerardpuig/ppa
sudo apt-get update
sudo apt install -y google-chrome-beta sublime-text filezilla gnome-tweaks ubuntu-restricted-extras ubuntu-cleaner rar unrar p7zip-full p7zip-rar
sudo snap install vlc
sudo apt install curl
curl -sL https://deb.nodesource.com/setup_lts.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 -y 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
gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
\curl -sSL https://get.rvm.io | bash
Enable "Run command as a login shell" in Terminal preferences then exit Terminal and open it again:
rvm install 3.2.2
rvm --default use 3.2.2
echo 'gem: --no-document' >> ~/.gemrc
gem update --system
gem install bundler
gem install rails
gem update
git config --global color.ui true
git config --global user.name "Dipen Chauhan"
git config --global user.email "[email protected]"
ssh-keygen -t rsa -b 4096 -C "[email protected]"
cat ~/.ssh/id_rsa.pub
Paste above output to: https://github.com/settings/ssh
ssh -T [email protected]
To clean partial packages, unused dependencies and apt-cache:
sudo apt-get autoclean
sudo apt-get autoremove
sudo apt-get clean
timedatectl set-local-rtc 1 --adjust-system-clock
In terminal
rails new myapp
cd myapp
Rails stores secrets in config/credentials.yml.enc. It uses config/master.key to encrypt the credentials file. credentials.ymc.enc is stored on Github but master.key file is not. To edit, in terminal:
EDITOR=subl
bin/rails credentials:edit
adduser deploy
adduser deploy sudo
exit
ssh-copy-id [email protected]
ssh-copy-id [email protected]
- Install Rails as described above
- Install and Setup Git as described above
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 focal 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
Get output of
which ruby
and paste it in file:
sudo nano /etc/nginx/conf.d/mod-http-passenger.conf
right after it says passenger_ruby.
Start NGINX
sudo service nginx start
sudo rm /etc/nginx/sites-enabled/default
sudo nano /etc/nginx/sites-enabled/myapp
Paste the following:
server {
listen 80;
listen [::]:80;
server_name _;
root /var/www/myapp/code/public;
passenger_enabled on;
passenger_app_env production;
location /cable {
passenger_app_group_name myapp_websocket;
passenger_force_max_concurrent_requests_per_process 0;
}
# Allow uploads up to 100MB in size
client_max_body_size 100m;
location ~ ^/(assets|packs) {
expires max;
gzip_static on;
}
}
sudo service nginx reload
cd /var
sudo mkdir www
cd www
sudo mkdir myapp
chown deploy: /var/www/myapp
cd myapp
git clone [email protected]:overdrivemachines/myapp.git code
cd code
bundle config set --local deployment 'true'
bundle config set --local without 'development test'
bundle install
chmod 700 config db
chmod 600 config/database.yml
# TODO: chmod for config/master.key and config/credentials.yml.enc
Make sure to copy master.key file from the dev computer to the production server.
bundle exec rake assets:precompile db:migrate RAILS_ENV=production
sudo service nginx restart
They are located at:
- Access Log: /var/log/nginx/access.log
- Error Log: /var/log/nginx/error.log
sudo apt-get install postgresql postgresql-contrib libpq-dev
sudo su - postgres
createuser --pwprompt deploy
createdb -O deploy myapp
psql -U deploy -W -h 127.0.0.1 -d myapp
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
sudo mysql_secure_installation
# Open the MySQL CLI to create the user and database
mysql -u root -p
If the above gives you an error, exectute the following and replace 'Password!' with your password:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Password!';
sudo snap install core; sudo snap refresh core
sudo apt remove certbot
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo ufw allow OpenSSH
sudo ufw delete allow 'Nginx HTTP'
sudo ufw allow 'Nginx Full'
ufw enable
sudo ufw status
systemctl status nginx
sudo certbot --nginx -d example.com -d www.example.com
sudo systemctl status snap.certbot.renew.service
sudo certbot renew --dry-run