Skip to content

Instantly share code, notes, and snippets.

@shreyans-padmani
Created April 3, 2025 13:04
Show Gist options
  • Save shreyans-padmani/b5ab6f8de81d4658daf33d04616037bd to your computer and use it in GitHub Desktop.
Save shreyans-padmani/b5ab6f8de81d4658daf33d04616037bd to your computer and use it in GitHub Desktop.
FoR EC2 With .net Live
ubuntu@ip-172-31-12-139:~$ history
1 sudo apt update && sudo apt upgrade -y
2 sudo apt install -y wget apt-transport-https software-properties-common
3 wget https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
4 sudo dpkg -i packages-microsoft-prod.deb
5 sudo apt update
6 sudo apt install -y dotnet-sdk-8.0
7 sudo apt update
8 sudo apt install -y dotnet-runtime-8.0
9 dotnet --version
10 ls
11 cd ./
12 ls
13 cd /var
14 ls
15 cd ../
16 ls
17 cd root
18 cd home
19 ls
20 cd ubuntu
21 ls
22 cd /var
23 cd www
24 cd publish/
25 dotnet CRM_Leadmanager.dll
26 sudo nano /etc/systemd/system/CRM_Leadmanager.service
27 sudo systemctl daemon-reload
28 sudo systemctl enable dotnet-app
29 sudo systemctl start dotnet-app
30 sudo systemctl daemon-reload
31 sudo systemctl start dotnet-app
32 sudo systemctl start CRM_Leadmanager
33 sudo systemctl enable CRM_Leadmanager
34 sudo systemctl Status CRM_Leadmanager
35 sudo systemctl status CRM_Leadmanager
36 sudo apt install -y nginx
37 sudo nano /etc/nginx/sites-available/CRM_Leadmanager
38 sudo ln -s /etc/nginx/sites-available/CRM_Leadmanager /etc/nginx/sites-enabled/
39 sudo systemctl restart nginx
40 sudo systemctl status CRM_Leadmanager
41 curl http://localhost:5000
42 curl http://localhost:5001
43 sudo systemctl status nginx
44 curl -I http://13.127.68.23/
45 sudo nano /etc/systemd/system/CRM_Leadmanager.service
46 sudo systemctl restart Ancoraceramica
47 sudo systemctl restart CRM_Leadmanager
48 sudo nano /etc/systemd/system/CRM_Leadmanager.service
49 sudo systemctl restart CRM_Leadmanager
50 sudo systemctl daemon-reload
51 sudo systemctl restart CRM_Leadmanager
52 curl -I http://13.127.68.23/
53 curl http://localhost:5000
54 curl http://13.127.68.23:5000
55 sudo systemctl status nginx
56 sudo systemctl restart nginx
57 sudo nano /etc/systemd/system/CRM_Leadmanager.service
58 sudo systemctl restart nginx
59 curl -I http://13.127.68.23/
60 sudo systemctl daemon-reload
61 sudo nano /etc/nginx/sites-available/CRM_Leadmanager
62 sudo nano /etc/systemd/system/CRM_Leadmanager.service
63 sudo systemctl daemon-reload
64 sudo systemctl restart nginx
65 curl http://localhost:5000
66 curl -I http://13.127.68.23/
67 curl http://13.127.68.23/
68 curl http://13.127.68.23:5000
69 sudo nano /etc/systemd/system/CRM_Leadmanager.service
70 sudo nano /etc/nginx/sites-available/CRM_Leadmanager
71 sudo nano /etc/nginx/sites-available/default
72 sudo nano /etc/nginx/sites-available/CRM_Leadmanager
73 sudo nano /etc/nginx/sites-available/default
74 sudo systemctl restart nginx
75 sudo systemctl daemon-reload
76 sudo nano /etc/systemd/system/CRM_Leadmanager.service
77 sudo systemctl daemon-reload
78 sudo systemctl restart nginx
79 sudo systemctl restart CRM_Leadmanager
80 sudo nano /etc/systemd/system/CRM_Leadmanager.service
81 sudo systemctl daemon-reload
82 sudo systemctl restart CRM_Leadmanager
83 sudo systemctl restart nginx
84 sudo nano /etc/systemd/system/CRM_Leadmanager.service
85 sudo systemctl daemon-reload
86 sudo systemctl restart nginx
87 sudo systemctl restart CRM_Leadmanager
88 sudo apt update && sudo apt upgrade -y
89 sudo apt install -y wget gnupg2
90 wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/postgresql.asc
91 echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
92 sudo systemctl enable postgresql
93 sudo systemctl start postgresql
94 sudo systemctl enable postgresql
95 sudo apt update
96 sudo apt install -y postgresql-16 postgresql-client-16
97 sudo systemctl enable postgresql
98 sudo systemctl start postgresql
99 sudo systemctl status postgresql
100 sudo -i -u postgres
101 psql
102 sudo -i -u postgres
103 sudo nano /etc/postgresql/16/main/postgresql.conf
104 history
ubuntu@ip-172-31-12-139:~$
ubuntu@ip-172-31-12-139:~$ sudo nano /etc/systemd/system/CRM_Leadmanager.service
ubuntu@ip-172-31-12-139:~$ sudo nano /etc/nginx/sites-available/default
ubuntu@ip-172-31-12-139:~$ sudo nano /etc/nginx/sites-available/CRM_Leadmanager
[Unit]
Description=.NET 8 Application
After=network.target
[Service]
WorkingDirectory=/var/www/publish
ExecStart=/usr/bin/dotnet /var/www/publish/CRM_Leadmanager.dll
Restart=always
User=ubuntu
Environment=DOTNET_ENVIRONMENT=Production
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
server {
listen 80;
server_name your-domain.com; # Replace with your domain or public IP
location / {
proxy_pass http://localhost:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 80;
server_name your-domain.com; # Replace with your domain or public IP
location / {
proxy_pass http://localhost:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment