Skip to content

Instantly share code, notes, and snippets.

@gladson
Last active October 11, 2015 02:57
Show Gist options
  • Save gladson/3792242 to your computer and use it in GitHub Desktop.
Save gladson/3792242 to your computer and use it in GitHub Desktop.
Configuração Virtualenvs Webfaction

PARA CHECAR A VERSÃO DO PYTHON

$ python -V

editar .bashrc

$ vi ~/.bashrc

para que fique default python to 2.7

$ alias python=python2.7  

salve :wq

source ~/.bashrc

crie a pasta na lib python2.7

mkdir $HOME/lib/python2.7

use easy_install para uma versão do python especifico

easy_install-2.7 pip easy_install-2.7 --install-dir=/lib/python2.7 --script-dir=/bin virtualenv

editar .bashrc

vi ~/.bashrc

crie a pasta virtualenvs

mkdir ~/.virtualenvs

para que fique workon_home and virtualenvwrapper_python

export WORKON_HOME=$HOME/.virtualenvs export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2.7

mude seu nome de usuario aqui

source /home//bin/virtualenvwrapper.sh export PIP_VIRTUALENV_BASE=$WORKON_HOME export PIP_RESPECT_VIRTUALENV=true
export VIRTUALENVWRAPPER_TMPDIR=$HOME/.virtualenvs/tmp source $HOME/bin/virtualenvwrapper.sh export PIP_VIRTUALENV_BASE=$WORKON_HOME export PIP_RESPECT_VIRTUALENV=true export TEMP=$HOME/tmp

salve :wq e ao sair fazer reload .bashrc

source ~/.bashrc

para instalar virtualenvwrapper

mkdir -p ~/bin ~/lib/python2.7 ~/src cd ~/src ln -s $HOME/lib/python2.7 $HOME/lib/python wget http://pypi.python.org/packages/source/v/virtualenvwrapper/virtualenvwrapper-3.6.tar.gz tar zxf virtualenvwrapper-3.6.tar.gz cd virtualenvwrapper-3.6 PYTHONPATH=$HOME/lib/python2.7 python2.7 setup.py install --home=$HOME rm $HOME/lib/python

para criar o env

mkvirtualenv mysite

para ativar o env

workon mysite

edite o arquivo wsgi.py

import os, sys, site

site.addsitedir('~/.virtualenvs/mysite/lib/python2.4/site-packages')

os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'

activate_this = os.path.expanduser("~/.virtualenvs/mysite/bin/activate_this.py") execfile(activate_this, dict(file=activate_this))

project = '~/webapps/mysite/myproject/' workspace = os.path.dirname(project) sys.path.append(workspace)

from django.core.handlers.wsgi import WSGIHandler application = WSGIHandler()

@alexandre-mbm
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment