The recent project team is on the Python+django. The deployment process is now summarized under the relevant files are also backed up, face every time to get a half day. Online a lot of bad practices, let me repeatedly trial and error, wasting a lot of time.
Raw materials:
Python3.6.2
Httpd-2.4.27-win64-vc14
Mod_wsgi-4.5.17+ap24vc14-cp36-cp36m-win_amd64.whl
Django-1.11.5
Description
Since Python2.7 will stop updating in the future, the company will use the latest version
Apache can not compile successfully, simply down, now use the 2.4 VC14 version, why use VC14, because Mod_wsgi the latest version only support to VC14
MOD_WSGI-4.5.17+AP24VC14-CP36-CP36M-WIN_AMD64.WHL: Let's explain:
Ap24vc14:apache 2.4 VC14 version
cp36-cp36m: This section refers to python3.6+
WIN_AMD64: It's just a 64-bit system
Remember here: Be sure to find several packages that are consistent with your system version, Python version, Apache version, or Die or die unsuccessfully.
Next: Let's talk about how to install:
1. Configure Apache
Apache24: Unzip it down as follows.
Here, we need to modify: Config file.
Near line 37: Modify the Apache path:
ServerRoot "D:/install/httpd-2.4.27-win64-vc14/apache24"
In this file. The default is C:/apache24. Replace one key with your actual path. can refer to
In the vicinity of Line 57, modify the listening port:
#Listen 12.34.56.78:80
Listen 8088
Then run Httpd.exe. Here, you need to run it in the command line. As long as the command line window is not returned, the run succeeds. Access using HTTP./ localhost:8088
2. Install Python and Pip
When installing python3.6.2, the PIP will be installed together. Then configure the environment variables. Online many of the very tutorial, casually refer to this document
3. Install Django
Refer to this document: Django Official documents can also be downloaded here
4. Use Mod_wsgi to get through Apache and Django
Note: Using mod_wsgi.so in a low version allows Django and Apache to be linked together. However, this version of WSGI does not have a. so file. So how do we load WSGI?
Copy your MOD_WSGI-4.5.17+AP24VC14-CP36-CP36M-WIN_AMD64.WHL file to the Python scripts directory and use
PIP3 Install MOD_WSGI-4.5.17+AP24VC14-CP36-CP36M-WIN_AMD64.WHL
For installation. You will then see the following:
PS c:\users\administrator\appdata\local\programs\python\python36\scripts> PIP3 Install C:\Users\Administrator\ Appdata\lo
Cal\programs\python\python36\scripts\mod_wsgi-4.5.17+ap24vc14-cp36-cp36m-win_amd64.whl
Requirement already satisfied:mod-wsgi==4.5.17+ap24vc14 from File:///C:/Users/Administrator/AppData/Local/Programs /PYTHON/PYTHON36/SCRIPTS/MOD_WSGI-4.5.17%2BAP24VC14-CP36-CP36M-WIN_AMD64.WHL in C:\users\administrator\appdata\ Local\programs\python\python36\lib\site-packages
PS c:\users\administrator\appdata\local\programs\python\python36\scripts> mod_wsgi-express Module-config
LoadFile "C:/users/administrator/appdata/local/programs/python/python36/python36.dll"
LoadModule Wsgi_module "C:/users/administrator/appdata/local/programs/python/python36/lib/site-packages/mod_wsgi /server/mod_wsgi.cp36-win_amd64.pyd "
Wsgipythonhome "C:/users/administrator/appdata/local/programs/python/python36"
PS c:\users\administrator\appdata\local\programs\python\python36\scripts>
Copy the Black font section from the Command-line window and place it in Apache Httpd.config
Position of the last LoadModule. About 180 rows or so.
Immediately after, write in:
#wsgi文件的位置
wsgiscriptalias/e:/workspace/pyworkspace/mycms/mycms/wsgi.py
#项目位置
Wsgipythonpath E:/workspace/pyworkspace/mycms
#设置脚本
<directory e:/workspace/pyworkspace/mycms/mycms>
<files wsgi.py>
Require all granted
SetHandler Wsgi-script
</Files>
</Directory>
5. Modify the Wsgi file:
Put the following code in the red box of the Wsgi file
Import Sys
Base_dir = Os.path.dirname (Os.path.dirname (Os.path.abspath (__file__)))
Sys.path.append (Base_dir)
So far, we've ended the Django deployment. In our views, there is such a return:
At this point, start Apache and enter your actual address:
PYTHON3.6.2+DJANGO-1.11.5+HTTPD-2.4.27-WIN64-VC14 Deployment Web site under Windows