Skip to content

Instantly share code, notes, and snippets.

@whittlem
Last active August 22, 2021 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whittlem/f26fa40a5a182c0e61e8ebb1890f6873 to your computer and use it in GitHub Desktop.
Save whittlem/f26fa40a5a182c0e61e8ebb1890f6873 to your computer and use it in GitHub Desktop.
aws-ec2-redhat-apache-python-flask.py
#!/bin/bash
yum repolist all
yum-config-manager --enable codeready-builder-for-rhel-8-rhui-rpms
yum --disablerepo=\* remove subscription-manager -y
yum update -y
yum install vim git wget httpd python39 python3-pip python39-mod_wsgi python3-markupsafe -y
python3 -m pip install virtualenv
systemctl enable httpd
dd if=/dev/zero of=/swapfile bs=128M count=32
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
swapon -s
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab
cd /etc/httpd/conf
wget https://gist.githubusercontent.com/whittlem/6f6f646cdddb3211cab7b2a166e7faee/raw/7bc915c2ec869729efc88c8eaa66fadd74f1f74d/apache-wsgi-vhost.conf
mv apache-wsgi-vhost.conf vhost.conf
echo "" >> httpd.conf
echo "Include conf/vhost.conf" >> httpd.conf
cd /var/www/html
wget https://gist.githubusercontent.com/whittlem/6ba6c38ecb9253c30448e4750f8ca73b/raw/3db48b6f82e99a6909621268a046ab5a2f84dcfa/python-flask-run.py
mv python-flask-run.py run.py
wget https://gist.githubusercontent.com/whittlem/f5bd7411db381f229e4fb4425deca503/raw/7e8cc85dcc40694b238a4df2585f629c30c94765/python-flask-wsgi.py
mv python-flask-wsgi.py wsgi.py
mkdir /var/www/html/app
cd /var/www/html/app
wget https://gist.githubusercontent.com/whittlem/ec124b44073c0a90a4dc71f5486f9398/raw/17ad65567c6823c8fa297b2700f10fdf151db616/python-flask-app_init.py
mv /var/www/html/app/python-flask-app_init.py __init__.py
cd /var/www
virtualenv --python=python3 html
cd /var/www/html
source bin/activate
pip install --upgrade pip
pip install flask
systemctl restart httpd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment