在CentOS 5 Linux環境下配置TurboGears 2.1

來源:互聯網
上載者:User
文章目錄
  • 1,環境準備
  • 2,設定虛擬環境並安裝TG21

 

1,環境準備

 

在CentOS 5.x Linux中,已經預設安裝了Python 2.4因此我們就在這個基礎上安裝TurboGears 2.1。

在寫這篇文章的時候,最新的TG21版本為rc1,我們就在這個基礎上進行安裝。

首先要安裝easy_install,建議用pypi.python.org上面最新的版本安裝,不要用yum安裝,CentOS內建的版本比較低。

用wget下載easy_install 0.6c11:

$ wget http://pypi.python.org/packages/2.4/s/setuptools/setuptools-0.6c11-py2.4.egg#md5=bd639f9b0eac4c42497034dec2ec0c2b

然後用sh執行下載後的.egg檔案:

$ sh ./setuptools-0.6c11-py2.4.egg

這樣就完成了setuptools的安裝。

下面安裝一個virtualenv軟體,這個軟體可以構造一個虛擬python環境,把turbogears安裝過程中下載的第三方軟體包都安裝到這個虛擬環境中,不至於影響系統本身的環境。而且你還可以建立多個虛擬環境,在不同的環境中嘗試不同的第三方軟體包。

直接用easy_install 安裝virtualenv。

$ easy_install virtualenv

到這裡,安裝所需要的環境就準備好了。

2,設定虛擬環境並安裝TG21

用virtualenv建立一個虛擬環境,然後在虛擬環境中安裝TurboGears 2.1

$ virtualenv --no-site-packages tg21env
$ cd tg21env/
$ source bin/activate
(tg21env)$ easy_install hashlib pysqlite uuid functools
(tg21env)$ easy_install -U beaker
(tg21env)$ easy_install -i http://www.turbogears.org/2.1/downloads/current/index tg.devtools
(tg21env)$ paster quickstart example
(tg21env)$ cd example/
(tg21env)$ python setup.py develop
(tg21env)$ nosetests
(tg21env)$ paster setup-app development.ini
(tg21env)$ paster serve development.ini

開啟瀏覽器,在地址欄輸入http://127.0.0.1:8080

 

安裝成功!

如果你想從其他的電腦訪問這台測試伺服器,那麼修改一下example目錄中的development.ini,在[server:main]中修改host值為0.0.0.0即可。

如果你想從虛擬環境中退出,鍵入:

(tg21env)$ deactivate

即可

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.