[Django]-How to install python3 and Django using userdata in AWS EC2 with aws cli boto3

5👍

Here is what I had to do get things working.

Here are the instructions to install python 3 and django on aws using boto3 within user-data

    UserData="""#!/bin/bash
            yum install httpd php php-mysql -y
            yum install python36 python36-virtualenv python36-pip -y
            pip install --upgrade pip
            cd /home/ec2-user
            python3 -m venv /home/ec2-user/venv
            source /home/ec2-user/venv/bin/activate
            pip install django
            pip install --upgrade pip
            yum update -y
            service httpd start
            chkconfig httpd on
            """

thanks to the tip from @dpwrussell I had to remove sudo since it’s not required. next, I had to change directory to get the virtual env under my user home.

Leave a comment