久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術(shù)文章
文章詳情頁

在Dreamhost上使用virtualenv更新新的Django和Python 2.7*(with passenger)

瀏覽:3日期:2022-08-07 15:12:33
(adsbygoogle = window.adsbygoogle || []).push({}); 如何解決在Dreamhost上使用virtualenv更新新的Django和Python 2.7*(with passenger)?

我目前有私人服務(wù)器,一個(gè)外殼帳戶和一點(diǎn)運(yùn)氣。所以這是我的工作:

SSH到你的主機(jī)以升級python

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配置系統(tǒng)以使用我們的新Python。打開?/ .bashrc并添加以下行

export PATH='$HOME/Python27/bin:$PATH' export LD_LIBRARY_PATH=$HOME/Python27/lib #save it and run source ~/.bashrc

你現(xiàn)在可以使用檢查你的python版本 which python

安裝easy_install,pip

cd ~/tmpwget http://peak.telecommunity.com/dist/ez_setup.pypython ez_setup.pyeasy_install pip# Or even shorterwget https://bootstrap.pypa.io/get-pip.pypython get-pip.py安裝 virtualenv

pip install virtualenv virtualenv $HOME/<site>/env #Switch to virtualenv source $HOME/<site>/env/bin/activate你還可以將env路徑添加到 bashrc

export PATH='$HOME/<site>/env/bin/:$PATH' source ~/.bashrc安裝django和其他所有東西

pip install django pip install .... pip install .... pip install ....建立專案

cd $HOME/<site>/ python $HOME/<site>/env/bin/django-admin.py startproject project創(chuàng)建passenger_wsgi.py于HOME//與下列內(nèi)容

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 < '2.7.3': os.execl('$HOME/<site>/env/bin/python', 'python2.7.3', *sys.argv) sys.path.insert(0,’$HOME/<site>/env/bin’) sys.path.insert(0,’$HOME/<site>/env/lib/python2.7/site-packages/django’) sys.path.insert(0,’$HOME/<site>/env/lib/python2.7/site-packages’) os.environ[’DJANGO_SETTINGS_MODULE’] = 'project.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WsgiHandler()

或者這樣

import sys, osBASE_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 pathPYTHON_PATH = os.path.join(BASE_DIR, ’env’, ’bin’, ’python’)if sys.executable != PYTHON_PATH: os.execl(PYTHON_PATH, 'python2.7.12', *sys.argv)

如果你使用的是django 1.7,請將最后兩行替換為

from django.core.wsgi import get_wsgi_applicationapplication = get_wsgi_application()

享受:DDreamhost上的新版本python將不再返回,sys.executable因此你這是我的passenger_wsgi版本

import sys, osVIRTUAL_ENV_PYTHON = ’venv-python’ # Python > 2.7.6 dreamhost not return sys.executableBASE_DIR = os.path.dirname(os.path.abspath(__file__))def is_venv_python(): if len(sys.argv) > 0:last_item = sys.argv[len(sys.argv)-1]if last_item == VIRTUAL_ENV_PYTHON: return True return Falsesys.path.append(os.path.join(BASE_DIR)) #You must add your project here or 500#Switch to new pythonPYTHON_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’))解決方法

Dreamhost是小型項(xiàng)目的理想主機(jī)。而且它也是Django友好的托管。除python和Django版本外,其他所有功能都過時(shí)了。好吧,這是一整天的工作,要弄清楚如何在dreamhost上更新Python 2.7.3,Django 1.4,我真的想與任何發(fā)現(xiàn)它的人分享

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 邻水| 天气| 寻乌县| 延边| 靖西县| 临漳县| 门头沟区| 凉城县| 行唐县| 青海省| 青岛市| 兰坪| 贵港市| 西城区| 泸定县| 鄂托克旗| 临泉县| 乌审旗| 肇庆市| 莲花县| 曲靖市| 宣城市| 渝中区| 临汾市| 衡山县| 渝北区| 泸定县| 临桂县| 彭山县| 安阳县| 汝城县| 夏津县| 桐城市| 确山县| 郓城县| 当涂县| 时尚| 上栗县| 明星| 望城县| 溧水县|