Steps
ssh -i key.pem ubuntu@YOUR_IP use this to login to your machine
nano [script.sh](<http://script.sh>) and paste the following contents# Update package list
sudo apt update
# Install software-properties-common with automatic confirmation
sudo apt install -y software-properties-common
# Add the deadsnakes PPA repository
sudo add-apt-repository ppa:deadsnakes/ppa
# Update package list again after adding the new repository
sudo apt update
# Install Python 3.10 with automatic confirmation
sudo apt install -y python3.10
# Install Nginx with automatic confirmation
sudo apt install -y nginx
# Install wget with automatic confirmation
sudo apt install -y wget
#Install pip
sudo apt install -y python3-pip
#Install venv
sudo apt install -y python3-venv
# Start Nginx service
sudo systemctl start nginx
# Enable Nginx to start on boot
sudo systemctl enable nginx
chmod +x script.ah to change the file permission to allow execution./script.sh to run the fileconfig.sh using nano
nano config.shPUBLIC_IP=$(wget -qO- <http://checkip.amazonaws.com>)
if [ -z "$PUBLIC_IP" ]; then
echo "Failed to retrieve public IP address."
exit 1
fi
# Create the Nginx configuration file content with the public IP
NGINX_CONFIG="server {
listen 80;
listen [::]:80;
server_name $PUBLIC_IP;
location / {
proxy_pass <http://127.0.0.1:5000>;
include proxy_params;
}
}"
# Write the configuration to /etc/nginx/sites-enabled/default
echo "$NGINX_CONFIG" | sudo tee /etc/nginx/sites-enabled/"$PUBLIC_IP" > /dev/null
# Restart Nginx to apply the changes
sudo systemctl restart nginx