Skip to content

Instantly share code, notes, and snippets.

@deepanshumehtaa
Last active August 20, 2026 20:15
Show Gist options
  • Select an option

  • Save deepanshumehtaa/cbc82439106d44b4c8b2461020c3c9c1 to your computer and use it in GitHub Desktop.

Select an option

Save deepanshumehtaa/cbc82439106d44b4c8b2461020c3c9c1 to your computer and use it in GitHub Desktop.
ubuntu server
configure wifi on ubuntu server:
need to update the yaml key-value pair:
check if it exists:
>> ls -l /etc/netplan/50-cloud-init.yaml
update:
>> sudo nano /etc/netplan/50-cloud-init.yaml
after update apply the settings:
>> sudo netplan apply
================================ Nginx ==================================
sudo apt update
sudo apt install -y nginx
sudo systemctl start nginx
sudo systemctl enable nginx
> sudo apt install certbot python3-certbot-nginx
firewall ..................................
sudo ufw allow 'Nginx Full'
sudo ufw allow <my port>
sudo ufw reload
# Steps:
1. first we need to config file in as `example.com` in `/etc/nginx/sites-available`
2. create symlink of these available sites to `/etc/nginx/sites-enabled/`
> sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
3. to see all symlinks:
> ls -l /etc/nginx/sites-enabled/
If you want to REMOVE symlink:
> sudo rm /etc/nginx/sites-enabled/something.com
port mapping with virtual servers...............................
default page:
sudo nano /etc/nginx/sites-available/default
add route of ur app, 192.186.x.x/my_app ──► http://localhost:8000 ....................
server {
listen 80 default_server;
listen [::]:80 default_server;
location /my_app/ {
proxy_pass http://localhost:8000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
restart the nginx server: sudo systemctl reload nginx
also, for python apps: `FastAPI(root_path="/my_app")`
logs ...................................
> cat /var/log/nginx/access.log
> cat /var/log/nginx/error.log
commands to see all the config files at one place:
> sudo nginx -T
*** Note ***:
If you want to deploy app ASAP with MIN effort, directly updated this `sudo nano /etc/nginx/sites-available/default`
default page
================================ ext media ===============================
>> lsblk
or
>> lsusb
================================ UV =======================================
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
uv pip install <pkg>
uv pip install -r requirements.txt
uv pip list
================================ ssh =======================================
sudo apt install openssh-server
sudo systemctl enable ssh
sudo systemctl start ssh
sudo systemctl status ssh
on server see the ip:
>> ip a
generate ssh key in laptop and paste the public key in `authorized_keys` file:
>> nano /home/deepanshu/.ssh/authorized_keys
on laptop:
>> ssh <server-username>@<ip>
to exit:
>> exit
==================================== systemd / servicectl ==================
>> ls /lib/systemd/system | head
create file:
sudo nano /etc/systemd/system/fastapi-myapp.service
content:
[Unit]
Description=FastAPI My App
After=network.target
[Service]
User=www-data
Group=www-data
WorkingDirectory=/my_app
# Activate venv by calling the venv's python directly
ExecStart=/my_app/venv/bin/uvicorn main:app \
--host 127.0.0.1 \
--port 8000
Restart=always
RestartSec=3
Environment="PYTHONUNBUFFERED=1"
[Install]
WantedBy=multi-user.target
>>
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl start fastapi-myapp
sudo systemctl status fastapi-myapp
sudo systemctl enable fastapi-myapp
======================================= MYSQL ==============================
sudo apt install mysql-server
sudo systemctl status mysql.service
mysql -u root -p
CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'secure_password';
CREATE USER 'new_user'@'%' IDENTIFIED BY 'secure_password';
GRANT ALL PRIVILEGES ON *.* TO 'new_user'@'localhost';
- or -
GRANT ALL PRIVILEGES ON database_name.* TO 'new_user'@'localhost';
==================================== cloud flare ===========================
[make sure you have cloudflare account created and you have ur domain if not cloudflare also gives you the domain else if you have with go dady change the namespace]
>> https://github.com/K0p1-Git/cloudflare-ddns-updater.git
update the .sh file with cloudflare creds
======================================OpenVPN ===================================
install access server:
>> bash <(curl -fsS https://packages.openvpn.net/as/install.sh) --yes
once you installed above check for the admin url (<ip>/admin) username (openvpn) and password (printed in terminal)
once u login, create group >> then user >> generate cert file (.ovm) in `Certificate Management`
place it in `/etc/openvpn/`
====================================== SSL/HttpS ===================================
==================================== SSH for CI/CD =================================
ssh-keygen -t ed25519 -C "your_email@example.com"
- private key:
goes to circle ci and with private key generate `fingerprint`
the generated fingerprint added to circleci/config.yaml file
- public key:
need to add to file authorized_keys in .ssh folder
1 MORE SSH key: for server & git repo::
> ssh-keygen -t ed25519 -b 4096 -C "server"
create on server and share the pub key with git-or-bitbucket in access token [access token are read-only token only for CICD & servers]
======================= Debug Docker on server ==============================================
>> docker ps --format "table {{.Names}}\t{{.Ports}}"
>> docker network inspect <container>
>> docker network ls
>> docker compose up --build
==================================== npm/node ===================================================
>> sudo apt install nodejs npm -y
>> sudo apt-get install -y nodejs
>> curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
============================== SSL certs =======================================================
for cloudFlare
1. go to `domain` & on left side options in list select ssl
2. select `Origin Server`
On server:
1. sudo mkdir -p /etc/nginx/ssl
2. create two files private.key & origin.crt
sudo chmod 600 /etc/nginx/ssl/private.key
sudo chmod 644 /etc/nginx/ssl/origin.crt
add to nginex config file under server section:
ssl_certificate /etc/nginx/ssl/origin.crt;
ssl_certificate_key /etc/nginx/ssl/private.key;
sudo systemctl reload nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment