Skip to content

Instantly share code, notes, and snippets.

@jamstooks
Last active May 30, 2023 06:17
Show Gist options
  • Save jamstooks/178408072a641381cbb636c3d1de1822 to your computer and use it in GitHub Desktop.
Save jamstooks/178408072a641381cbb636c3d1de1822 to your computer and use it in GitHub Desktop.
Notes on starting up an AWS Cloud9 Django dev environment with Python3
sudo yum -y update
# start by changing `alias python=python27` to `alias python=python3` in ~/.bashrc
sudo pip-3.6 install --upgrade pip
# for some reason `pip` is not found with sudo, so I use the full path.
sudo /usr/local/bin/pip install virtualenvwrapper
echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3" >> ~/.bashrc
echo "export WORKON_HOME=$HOME/environment/Envs" >> ~/.bashrc
echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.bashrc
echo "export PS1='\[\e]0;\w\a\]\[\e[32m\]\u:\[\e[33m\]\w\[\e[0m\]\n\$ '" >> ~/.bashrc
source ~/.bashrc
mkvirtualenv -p /usr/bin/python3 p3
mkvirtualenv -p /usr/bin/python2.7 p2
# for testing, I sometimes create many virtual envs, like p2-dj1-10
# OPTIONAL: remove `alias python=python3` altogether in ~/.bashrc
echo "alias dj='python manage.py'" >> ~/.bashrc
echo "alias djr='dj runserver \$IP:\$PORT'" >> ~/.bashrc
echo "alias djt='dj test'" >> ~/.bashrc
echo "alias djs='dj shell'" >> ~/.bashrc
# Set up git profile
git config --global user.email "[email protected]"
# confirm
git config --global user.email
# https://help.github.com/articles/connecting-to-github-with-ssh/
ssh-keygen -t rsa -b 4096 -C "[email protected]"
# add to github
ssh -T [email protected]
# Postgresql setup
# https://medium.com/@floodfx/setting-up-postgres-on-cloud9-ide-720e5b879154
sudo yum install postgresql postgresql-server postgresql-devel postgresql-contrib postgresql-docs
sudo service postgresql initdb
# Follow instructions in blog post... OR write the sed command yourself :)
sudo service postgresql start
sudo su - postgres
psql -U postgres
CREATE USER "ec2-user" SUPERUSER;
# also consider
# ALTER ROLE "ec2-user" SET client_encoding TO 'utf8';
# ALTER ROLE "ec2-user" SET default_transaction_isolation TO 'read committed';
# ALTER ROLE "ec2-user" SET timezone TO 'UTC';
# MongoDB
# https://docs.mongodb.com/manual/tutorial/install-mongodb-on-amazon/
sudo service mongod start
# MySQL mysql55 is already installed
sudo service mysqld start
# Add github ssh connection
# https://help.github.com/articles/connecting-to-github-with-ssh/
# Node setup
# use nvm: https://github.com/creationix/nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
nvm install node
nvm use node
# https://yarnpkg.com/lang/en/docs/install/#centos-stable
sudo yum install yarn
# A little extra for easy access to vars
# Really only necessary if you're going to need remote access
# https://docs.aws.amazon.com/cloud9/latest/user-guide/app-preview.html#app-preview-share
echo "export INSTANCE_ID=\`curl http://169.254.169.254/latest/meta-data/instance-id\`" >> ~/.bashrc
echo "export PUBLIC_IP=\`curl http://169.254.169.254/latest/meta-data/public-ipv4\`" >> ~/.bashrc
# if you're using ipv4 [ref](https://stackoverflow.com/a/26694162/295789):
echo "export PRIVATE_IP=\`ip -4 addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'\`" >> ~/.bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment