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
| CREATE USER 'user'@'localhost' IDENTIFIED BY 'passwd'; | |
| CREATE DATABASE db_name; | |
| GRANT ALL PRIVILEGES ON db_name.* TO 'user'@'localhost'; | |
| FLUSH PRIVILEGES; | |
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
| # Fix permission to files | |
| find . -type f -exec chmod 0644 {} \; | |
| find . -type d -exec chmod 0755 {} \; | |
| # Fix perms to all files excluding .git repo directory | |
| find . -type f -prune -o -name .git -exec chmod 0644 {} \; | |
| find . -type d -prune -o -name .git -exec chmod 0775 {} \; |
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
| # add all: Changes not staged for commit | |
| git ls-files --modified | xargs git add |
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
| lsof -iTCP -sTCP:LISTEN |
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
| cp -r app/views app/views-backup | |
| cd app/views | |
| for x in `find . -iname \*erb`; do erb2slim $x ; done | |
| rm -f `find . -iname \*erb` |
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
| # Recommended first steps on fresh server: | |
| # https://gist.github.com/mkacz/3c3be134972a2a6688b4c77d8c86740b | |
| # Install nginx | |
| sudo add-apt-repository ppa:nginx/stable | |
| sudo apt update | |
| sudo apt install -y nginx | |
| # Install postgresql | |
| echo "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main" > /etc/apt/sources.list.d/pgdg.list |
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
| # Upgrade | |
| apt update -y | |
| apt upgrade | |
| # Inspect & remove what's not needed: | |
| w | |
| cat /etc/passwd | |
| netstat -nlp | |
| dpkg -l | |
| ps -Af |
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
| # Creating dump # (If dump for Heroku add: --no-acl --no-owner) | |
| pg_dump -h localhost -U db_user db_name > dump_file.sql | |
| # Restoring dump | |
| sudo su postgres | |
| createuser -P --interactive db_owner | |
| createdb db_name --owner=db_owner --encoding=utf8 -l en_US.utf8 -T template0 | |
| # Optional if dump has been done withoud --no-acl --no-owner opts |
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
| # Install certbot on Ubuntu | |
| # https://certbot.eff.org/#ubuntuxenial-nginx | |
| # https://certbot.eff.org/docs/using.html#getting-certificates-and-choosing-plugins | |
| $ sudo apt-get install software-properties-common | |
| $ sudo add-apt-repository ppa:certbot/certbot | |
| $ sudo apt-get update | |
| $ sudo apt-get install certbot python-certbot-nginx | |
| # vhost definition must be placed in /etc/nginx/sites-enabled/domain.tld |
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
| # Older than 18.04-lts | |
| # apt install gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev | |
| apt install gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev | |
| git clone https://github.com/rbenv/rbenv.git ~/.rbenv | |
| cd ~/.rbenv && src/configure && make -C src | |
| echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile | |
| echo 'eval "$(rbenv init -)"' >> ~/.bash_profile | |
| logout |