Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> 電腦軟體教學 >> 伺服器技術 >> 關於伺服器

Windows 下手把手部署 Python 2.5 + Django 1.0 開發環境

編輯:關於伺服器

環境版本鎖定 (教學用舊版本,實務請升級至 Python 3.x + Django 4.x)

  • Python 2.5.4 (MSI 安裝包)
  • Django 1.0.2 (源碼包)
  • MySQL 5.x (已安裝)
  • MySQL-python (Windows 二進位安裝包)

步驟 1:安裝 Python 並加入 PATH

  1. 執行 python-2.5.4.msi,預設安裝至 C:\Python25。
  2. 「我的電腦」→ 右鍵「內容」→「進階」→「環境變數」→ 系統變數 Path 追加 ;C:\Python25;C:\Python25\Scripts。

步驟 2:安裝 MySQL-python

執行 MySQL-python-1.2.3.win32-py2.5.exe (版本需對應 Python 2.5),自動寫入 site-packages。

步驟 3:安裝 Django

  1. 解壓 Django-1.0.2.tar.gz 至任意目錄 (如 D:\Django-1.0.2)。
  2. 命令列 cd D:\Django-1.0.2 → python setup.py install。
  3. 將 django-admin.py 所在目錄 (C:\Python25\Scripts) 已在 PATH 中,無需額外設定。

步驟 4:建立第一個專案並啟動開發伺服器

cd D:\Projects
django-admin.py startproject hello
cd hello
python manage.py runserver

瀏覽器開啟 https://127.0.0.1:8000/ 出現 It worked! 即成功。

重要提醒

  • 內建 runserver 僅供開發測試,**嚴禁生產環境使用**。
  • 生產部署請採用 Gunicorn/uWSGI + Nginx (Linux) 或 IIS + wfastcgi (Windows)。
  • Python 2.5、Django 1.0 已停止維護,含已知安全漏洞,**新專案請直接使用 Python 3.10+ / Django 4.2 LTS**。
Copyright © Windows教程網 All Rights Reserved