Skip to content

Instantly share code, notes, and snippets.

@JudahSan
Forked from hmasila/ubuntu.md
Created September 10, 2024 13:45
Show Gist options
  • Save JudahSan/fc4319a23ab366dfb6ded3a142873e9f to your computer and use it in GitHub Desktop.
Save JudahSan/fc4319a23ab366dfb6ded3a142873e9f to your computer and use it in GitHub Desktop.

Create deploy user

$ sudo adduser deploy

Privileges

Sudoer

add "deploy" user to sudo group if you want deploy to be a sudoer

$ sudo usermod -aG sudo deploy

verify if the user has been added to the sudo group result should include "sudo" for the deploy user $ groups deploy

Non-sudoer

If you don't want deploy to be a sudoer, you can add the privileges independently

$ visudo

Add your new user privileges under root & ctrl+x then y to save

deploy ALL=(ALL:ALL) ALL

Login as deploy

$ su deploy

Add your ssh keys

Si unajua kufanya hiyo

Install dependencies

sudo apt install build-essential libpq-dev libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev autoconf bison postgresql postgresql-contrib

Install Rbenv

$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv

$ echo 'eval "$(~/.rbenv/bin/rbenv init - bash)"' >> ~/.bashrc

$ source ~/.bashrc

Install Ruby Build

git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build

Install your Ruby version

$ rbenv install 3.1.2

install Nvm

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

$ source ~/.bashrc

Install your node version

$ nvm install 16.10.0

Install Yarn

Via Curl

$ sudo curl --compressed -o- -L https://yarnpkg.com/install.sh | bash

$ source ~/.bashrc

Via npm

$ npm install -g yarn

Install redis

$ curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg

$ echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list

$ sudo apt-get update

$ sudo apt-get install redis redis-server

$ sudo vi /etc/redis/redis.conf

change supervised from auto to systemd

$ sudo systemctl restart redis-server

Setup the database

Login as postgres user

$ su - postgres

Connect to postgres

$ psql

Create deploy user and production database

CREATE USER deploy WITH PASSWORD 'S3Cur3Pa$&W0rD' CREATEDB;

CREATE DATABASE myapp_production;

GRANT ALL PRIVILEGES ON DATABASE spectralhub_production TO deploy;

\q to exit postgres

ctrl+D to exit out of postgres user

Start Postgres

$ sudo systemctl restart postgresql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment