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

您的位置:首頁技術文章
文章詳情頁

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

瀏覽:20日期:2022-08-07 08:47:17
如何解決在Dreamhost上使用virtualenv更新新的Django和Python 2.7。*(with passenger)?

我目前有私人服務器,一個外殼帳戶和一點運氣。所以這是我的工作:

SSH到你的主機以升級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配置系統以使用我們的新Python。打開?/ .bashrc并添加以下行

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

你現在可以使用檢查你的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創建passenger_wsgi.py于HOME//與下列內容

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是小型項目的理想主機。而且它也是Django友好的托管。除python和Django版本外,其他所有功能都過時了。好吧,這是一整天的工作,要弄清楚如何在dreamhost上更新Python 2.7.3,Django 1.4,我真的想與任何發現它的人分享

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 湘阴县| 张家港市| 饶平县| 广昌县| 界首市| 龙川县| 涞源县| 留坝县| 绥德县| 澄迈县| 雷州市| 淄博市| 句容市| 项城市| 霍邱县| 湄潭县| 利川市| 含山县| 安陆市| 安吉县| 张掖市| 新乐市| 县级市| 沧州市| 盐津县| 井陉县| 承德市| 江都市| 神池县| 嵊州市| 普洱| 迁安市| 文水县| 石景山区| 呼伦贝尔市| 墨江| 德阳市| 惠东县| 通河县| 乌海市| 渑池县|