Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I currently have private server, a shell account and a bit of luck. So here is what I do:</p> <ol> <li><p>SSH to your host to upgrade python</p> <pre><code> cd ~ mkdir tmp cd tmp wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz tar zxvf Python-2.7.3.tgz cd Python-2.7.3 ./configure --enable-shared --prefix=$HOME/Python27 --enable-unicode=ucs4 make make install </code></pre></li> <li><p>Configure system to use our new Python. Open ~/.bashrc and add the following line</p> <pre><code> export PATH="$HOME/Python27/bin:$PATH" export LD_LIBRARY_PATH=$HOME/Python27/lib #save it and run source ~/.bashrc </code></pre> <p>you can now check your python version with <code>which python</code></p></li> <li><p>Install <code>easy_install</code>, <code>pip</code></p> <pre><code>cd ~/tmp wget http://peak.telecommunity.com/dist/ez_setup.py python ez_setup.py easy_install pip # Or even shorter wget https://bootstrap.pypa.io/get-pip.py python get-pip.py </code></pre></li> <li><p>Install <code>virtualenv</code></p> <pre><code> pip install virtualenv virtualenv $HOME/&lt;site&gt;/env #Switch to virtualenv source $HOME/&lt;site&gt;/env/bin/activate </code></pre> <p>you can also add env path to <code>bashrc</code></p> <pre><code> export PATH="$HOME/&lt;site&gt;/env/bin/:$PATH" source ~/.bashrc </code></pre></li> <li><p>Install django and everything else</p> <pre><code> pip install django pip install .... pip install .... pip install .... </code></pre></li> <li><p>Create project</p> <pre><code> cd $HOME/&lt;site&gt;/ python $HOME/&lt;site&gt;/env/bin/django-admin.py startproject project </code></pre></li> <li><p>Create <code>passenger_wsgi.py</code> in <code>HOME/&lt;site&gt;/</code> with following content</p> <pre><code> import sys, os cwd = os.getcwd() sys.path.append(cwd) sys.path.append(cwd + '/project') #You must add your project here or 500 #Switch to new python #You may try to replace $HOME with your actual path if sys.version &lt; "2.7.3": os.execl("$HOME/&lt;site&gt;/env/bin/python", "python2.7.3", *sys.argv) sys.path.insert(0,'$HOME/&lt;site&gt;/env/bin') sys.path.insert(0,'$HOME/&lt;site&gt;/env/lib/python2.7/site-packages/django') sys.path.insert(0,'$HOME/&lt;site&gt;/env/lib/python2.7/site-packages') os.environ['DJANGO_SETTINGS_MODULE'] = "project.settings" import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() </code></pre></li> </ol> <p>or this way</p> <pre><code>import sys, os BASE_DIR = os.path.dirname(os.path.abspath(__file__)) sys.path.append(os.path.join(BASE_DIR)) #You must add your project here or 500 #Switch to new python #You may try to replace $HOME with your actual path PYTHON_PATH = os.path.join(BASE_DIR, 'env', 'bin', 'python') if sys.executable != PYTHON_PATH: os.execl(PYTHON_PATH, "python2.7.12", *sys.argv) </code></pre> <p>If you are using django 1.7, replace the last two line with</p> <pre><code>from django.core.wsgi import get_wsgi_application application = get_wsgi_application() </code></pre> <ol start="8"> <li>Enjoy :D</li> </ol> <hr> <p>New version of python on Dreamhost will no longer return <code>sys.executable</code> so you this is my version of passenger_wsgi</p> <pre><code>import sys, os VIRTUAL_ENV_PYTHON = 'venv-python' # Python &gt; 2.7.6 dreamhost not return sys.executable BASE_DIR = os.path.dirname(os.path.abspath(__file__)) def is_venv_python(): if len(sys.argv) &gt; 0: last_item = sys.argv[len(sys.argv)-1] if last_item == VIRTUAL_ENV_PYTHON: return True return False sys.path.append(os.path.join(BASE_DIR)) #You must add your project here or 500 #Switch to new python PYTHON_PATH = os.path.join(BASE_DIR, 'env', 'bin', 'python') if not is_venv_python(): os.execl(PYTHON_PATH, "python2.7.12", *sys.argv + [VIRTUAL_ENV_PYTHON]) sys.path.insert(0, os.path.join(BASE_DIR, 'env', 'bin')) sys.path.insert(0, os.path.join( BASE_DIR, 'env', 'lib', 'python2.7', 'site-packages' )) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload