current position:Home>windows10+apache2. 4 + Django deployment
windows10+apache2. 4 + Django deployment
2022-01-31 13:24:13 【BGLB】
windows10+apache2.4+django Deploy
During deployment , A lot of holes Take notes
Introduction to the environment
- python 3.7
- apache 2.4.15
- django 2.1
- windows10
install apache2.4
the latest version apache2.4 : httpd-2.4.51-win64-VS16
- Decompress after downloading
- take
Apache24
Copy the folder to your ownThe installation path
I put it directly here C discC:/Apache24
, Because the current online is on C disc Maybe it's for the convenience of installation Let's see what's inside
- add to
apache
environment variable
APACHE_HOME=C:\Apache24
PATH= %APACHE_HOME%; %APACHE_HOME%\bin
Environment variables are added directly to the system environment variables , There is no mapping here
- The installation to windows service
# install
httpd -k install -n The service name
# start-up
1. httpd -k start [stop, restart]
# perhaps
2. net start The service name
Copy code
There are many ways to start It can also be opened bin In the catalog ApacheMonitor.exe
But he won't pop up after double clicking , It will be in the tray in the lower right corner
then Double click the tray icon You can open it It looks like this
If no error is reported during startup , You can open the browser , Visit 127.0.0.1 No accident You can see that It’s Work!
Only this and nothing more , Apache installation is complete
Deploy Django
-
download
mod_wsgi
Use pip install
mod_wsgi.whl
file , Use pip Many words You should knowWhy install ? I don't know Be similar to
linux
Upperuwsgi
If not installed before , Just do it , If you step on the pit It's necessary to step on more
mod_wsgi Download address : mod_wsgi download
Open the link above Search with you python The version corresponds to
Pay attention here , If you use python A virtual environment Deploy django Words need Install... In a virtual environment ( Virtual environment is recommended )
# Enter the virtual environment ...\env\Scripts\activate pip install Download the mod_wsgi route # After installation It's best to see if it's successful pip list | findStr "mod_wsgi" Copy code
-
modify Apache Default profile
C:\Apache24\conf\httpd.conf
Before the change stay django In the virtual environment need Run it
mod_wsgi-express module-config
After running Three paths will be returned like this
LoadFile "C:/Users/Administrator/AppData/Local/Programs/Python/Python37/python37.dll" LoadModule wsgi_module "e:/development/django_project/env/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd" WSGIPythonHome "e:/development/django_project/env" Copy code
Be sure to generate your own , Don't use my !
Put the path above Copy To
apache
In the configuration file also modifyListen
andServerName
...... Define SRVROOT "C:/Apache24" ServerRoot "${SRVROOT}" ...... #Listen 12.34.56.78:80 # Here I change it to 9000 Listen 9000 ...... ServerName localhost:9000 ...... # load mod_wsgi LoadFile "C:/Users/Administrator/AppData/Local/Programs/Python/Python37/python37.dll" LoadModule wsgi_module "e:/development/django_project/env/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd" WSGIPythonHome "e:/development/django_project/env" # Set project path WSGIPythonPath E:\development\django_project # Set up Django In the project wsgi route WSGIScriptAlias / E:\development\django_project\django_project\wsgi.py # Set up wsgi File permissions <Directory E:\development\django_project\django_project> <Files wsgi.py> Require all granted </Files> </Directory> # Set static file path Do path mapping Alias /assets E:\development\online\django_project\static # Set static path permissions <Directory E:\development\online\django_project\static> AllowOverride None Options None Require all granted </Directory> Copy code
-
restart Apache
httpd -k resfart
The above command There is no prompt after running
net stop apache24
net start apache24
The top two There are relevant tips At least I'll tell you Whether the startup is successful or not
If you fail Just go to
C:\Apache24\logs
Catalog see dependenterror
journalOkay Back to the point
Usually at this time If nothing happens There should be an accident !
my Apache ad locum Can't start , The log is as follows :
Fatal Python error: initfsencoding: unable to load the file system codec ModuleNotFoundError: No module named 'encodings'
To see this Feel familiar I guess it was before Toss about u Discoid python I have seen
Because of this encdings yes python A library of its own therefore I'll go to this machine python The path of this library is viewed under the path And added it to In the system environment variable
however Still can't solve Last It's found This article window2008 Next ,apache+mod_msgi+flask Problems arise , Please help me have a look
He is Added
PYTHONHOMW
andPYTHONPATH
PYTHONHOME="C:\Users\Administrator\AppData\Local\Programs\Python\Python37" PYTHONPATH="C:\Users\Administrator\AppData\Local\Programs\Python\Python37\Lib"
And then when we're done Need to restart the machine
do not know why ????? After I try, I can start
End of deployment
At that time Problems encountered Now I've forgotten , It was the day before yesterday , The brain really doesn't work
Have the time Try again apache Multi site deployment
copyright notice
author[BGLB],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/01/202201311324121666.html
The sidebar is recommended
- [algorithm learning] 1108 IP address invalidation (Java / C / C + + / Python / go / trust)
- Test platform series (71) Python timed task scheme
- Java AES / ECB / pkcs5padding encryption conversion Python 3
- Loguru: the ultimate Python log solution
- Blurring and anonymizing faces using OpenCV and python
- How fast Python sync and async execute
- Python interface automation test framework (basic) -- common data types list & set ()
- Python crawler actual combat, requests module, python realizes capturing video barrage comments of station B
- Python: several implementation methods of multi process
- Sword finger offer II 054 Sum of all values greater than or equal to nodes | 538 | 1038 (Java / C / C + + / Python / go / trust)
guess what you like
-
How IOS developers learn python programming 3-operator 2
-
How IOS developers learn python programming 2-operator 1
-
[Python applet] 8 lines of code to realize file de duplication
-
Python uses the pynvml tool to obtain the working status of GPU
-
Data mining: Python actual combat multi factor analysis
-
Manually compile opencv on MacOS and Linux and add it to Python / C + + / Java as a dependency
-
Use Python VTK to batch read 2D slices and display 3D models
-
Complete image cutting using Python version VTK
-
Python interface automation test framework (basic) -- common data types Dict
-
Django (make an epidemic data report)
Random recommended
- Python specific text extraction in actual combat challenges the first step of efficient office
- Daily python, Part 8 - if statement
- Django model class 1
- The same Python code draws many different cherry trees. Which one do you like?
- Python code reading (Chapter 54): Fibonacci sequence
- Django model class 2
- Python crawler Basics
- Mapping 3D model surface distances using Python VTK
- How to implement encrypted message signature and verification in Python -- HMAC
- leetcode 1945. Sum of Digits of String After Convert(python)
- leetcode 2062. Count Vowel Substrings of a String(python)
- Analysis of Matplotlib module of Python visualization
- Django permission management
- Python integrated programming -- visual hot search list and new epidemic situation map
- [Python data collection] scripy realizes picture download
- Python interface automation test framework (basic part) -- loop statement of process control for & while
- Daily python, Chapter 9, while loop
- Van * Python | save the crawled data with docx and PDF
- Five life saving Python tips
- Django frequency control
- Python - convert Matplotlib image to numpy Array or PIL Image
- Python and Java crawl personal blog information and export it to excel
- Using class decorators in Python
- Untested Python code is not far from crashing
- Python efficient derivation (8)
- Python requests Library
- leetcode 2047. Number of Valid Words in a Sentence(python)
- leetcode 2027. Minimum Moves to Convert String(python)
- How IOS developers learn Python Programming 5 - data types 2
- leetcode 1971. Find if Path Exists in Graph(python)
- leetcode 1984. Minimum Difference Between Highest and Lowest of K Scores(python)
- Python interface automation test framework (basic) -- basic syntax
- Detailed explanation of Python derivation
- Python reptile lesson 2-9 Chinese monster database. It is found that there is a classification of color (he) desire (Xie) monsters during operation
- A brief note on the method of creating Python virtual environment in Intranet Environment
- [worth collecting] for Python beginners, sort out the common errors of beginners + Python Mini applet! (code attached)
- [Python souvenir book] two people in one room have three meals and four seasons: 'how many years is it only XX years away from a hundred years of good marriage' ~?? Just come in and have a look.
- The unknown side of Python functions
- Python based interface automation test project, complete actual project, with source code sharing
- A python artifact handles automatic chart color matching