Code Monkey home page Code Monkey logo

ec2_useful_info's Introduction

Linux Commands

  • Update System Packages sudo apt update && sudo apt upgrade -y
  • Install Essential Packages sudo apt install -y vim htop wget curl

Python

  • Install Python sudo apt install python3
  • Install Python-Pip sudo apt install python3-pip
  • Install App Requirements sudo pip3 install -r requirements.txt

NGINX

  • Install Nginx sudo apt install nginx
  • Start Nginx sudo systemctl start nginx
  • Stop Nginx sudo systemctl stop nginx
  • Restart Nginx sudo systemctl restart nginx
  • Disable Nginx at Server Start sudo systemctl disable nginx
  • Enable Nginx at Server Start sudo systemctl enable nginx
  • Change Ownership Ubuntu sudo chown -R ubuntu /etc/nginx
  • Check Config File sudo nginx -t

CERTBOT

  • Install Certbot sudo snap install --classic certbot
  • Request Certificate sudo certbot certonly
  • Renew Certificate sudo certbot renew
  • Check Certificate sudo certbot certificates
  • Check Certificate Auto Renewal sudo certbot renew --dry-run
  • Change Ownership Ubuntu sudo chown -R ubuntu /etc/letsencrypt/live

TMUX

  • Install TMUX sudo apt-get install tmux
  • Create Streaming Session tmux new -s Session_Name
  • Reattach Streaming Session tmux attach -t Session_Name
  • Kill Streaming Session tmux kill -t Session_Name
  • Exit Bash Ctrl+B and then D
  • Running Sessions tmux ls

Streamlit

  • Run Streamlit Temporary python3 -m streamlit run app.py

  • Run Streamlit Permanent nohup python3 -m streamlit run app.py

  • Config file for EC2 Instance sudo nano /home/ubuntu/.local/lib/python3.10/site-packages/streamlit/config.toml

     [server]
     port=8501 # Default Streamlit uses 8501 port
     headless=true # This will eliminate automatically open browser
     # enableCORS=false
     # enableXsrfProtection=false
     # enableWebsocketCompression=false[browser]
     serverAddress = "domain.xyz" # Put your Local IP or Domain Name
     serverPort = 8501`
    

NGINX Default config file with HTTPS settings

server {
        listen 443 ssl;
        server_name  domain.xyz; # Put your Local IP or Domain Name
  
        ssl_certificate /etc/letsencrypt/live/domain.xyz/fullchain.pem; # Put Cerbot provide path
        ssl_certificate_key /etc/letsencrypt/live/domain.xyz/privkey.pem; # Put Cerbot provide path
  
        proxy_http_version 1.1; 
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
	
	root /var/www/html;
}

NGINX Streamlit config file

server {
        listen 443 ssl;
        server_name  domain.xyz; # Put your Local IP or Domain Name
  
        ssl_certificate /etc/letsencrypt/live/domain.xyz/fullchain.pem; # Put Cerbot path
        ssl_certificate_key /etc/letsencrypt/live/domain.xyz/privkey.pem; # Put Cerbot path
  
        proxy_http_version 1.1; 
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
	
	root /var/www/html;

        # Streamlit specific: 
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 86400;
 
        location / {
            proxy_pass http://127.0.0.1:8501; # Streamlit Default Port 8501
        }
}

ec2_useful_info's People

Contributors

pyfihub avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.