Last active
June 9, 2018 01:55
-
-
Save havencruise/8307140 to your computer and use it in GitHub Desktop.
Django + Python2.7 + Apache setup for AWS EC2 with mod_wsgi A how-to on setting up Python 2.7, Django and mod_wsgi, and using Python 2.7 with virtual_env(which is the right thing to do) on Amazon EC2 instances. ..
..
..
Why? - Because Amazon EC2 instances usually come with Python 2.6 by default.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You will need to run these with superuser permissions. | |
# Either prefix `sudo` to all commands, or switch user | |
# Be very careful when you switch user | |
sudo su - root | |
# Update all the packages | |
yum update | |
# Install the basics - python27, gcc, svn, git, httpd, make, uuid | |
yum install python27 python27-devel gcc gcc-c++ subversion git httpd make uuid libuuid-devel | |
# We'll need this for building mod_wsgi | |
yum install httpd-devel | |
# Get mod_wsgi | |
curl -O https://modwsgi.googlecode.com/files/mod_wsgi-3.4.tar.gz | |
tar -xvf mod_wsgi-3.4.tar.gz | |
cd mod_wsgi-3.4 | |
# Configure for Python 2.7 using python27 path | |
./configure --with-python=/usr/bin/python27 | |
make; make install | |
# Once done, we need to tell apache about our new module | |
echo 'LoadModule wsgi_module modules/mod_wsgi.so' > /etc/httpd/conf.d/wsgi.conf | |
# Optionally, install Python Imaging, Mysql, Mysql-server, boost | |
yum install python27-imaging mysql mysqld boost boost-devel | |
# Get virtual_env to setup your django environment | |
curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.9.1.tar.gz | |
tar -xvf virtualenv-1.9.1.tar.gz | |
# Debate all you want, but the right thing to do is install packages for python27 in a virtual_env. | |
python27 virtualenv-1.9.1/virtualenv.py /opt/virtual-env-27 | |
source /opt/virtualenv-27/bin/activate | |
# Good news, you're ready to go when you see this prompt. | |
(virtualenv-27)$ pip install Django==1.6 | |
# Go ahead to clone your code or setup chef or | |
# whatever you do to deploy. :) | |
# Don't forget to setup your virtual host for httpd | |
service httpd start | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment