Configuration for deploying Django to Apache24, djangoapache24
1. first, download the latest version of Apachehttp: // httpd.apache.org/download.cgi?apache24. currently, the official website only needs to download the Windows msi installation package. After downloading the package, directly decompress the package to drive C, you need to modify the configuration file. Replace the following path.
Open C: \ apache24 \ conf \ httpd. conf in notepad and modify line 37 ServerRoot "c:/Apache24" => ServerRoot "c:/Apache24 "(Here, we enter the location where you extract the apache installation package.)
Modify row 217 # ServerName www.example.com: 80 => ServerName www.example.com: 80
Modify Row 3 DocumentRoot "c:/Apache24/htdocs" => DocumentRoot "c:/Apache24/htdocs"
Modify row 242 <Directory "c:/Apache24/htdocs" >=> <Directory "c:/Apache24/htdocs">
Modify 358 lines of ScriptAlias/cgi-bin/"c:/Apache24/cgi-bin/" => ScriptAlias/cgi-bin/"c:/Apache24/cgi-bin /"
Modify row 374 <Directory "c:/Apache24/cgi-bin" >=> <Directory "c:/Apache24/cgi-bin">
Double-click "c: \ apache24 \ bin \ ApacheMonitor.exe" and click "apache24" in the window to start http: // localhost/. If It works is displayed, the installation is successful.
2.Download mod_wsgiHttp://www.lfd.uci.edu /~ Gohlke/pythonlibs/# mod_wsgi: Put the obtained mod_wsgi.so in Apache24/modules.
Open apache24/conf/httpd. conf and add LoadModule wsgi_module modules/mod_wsgi.so to the corresponding location.
Open apachemonitor.exe and restart Apache24. If it starts properly, open Apache24/logs/error. log and you can see mod_wsgi: Runtime using Python/2.7.8. mod_wsgi is successfully installed.
3. Open C: \ apache24 \ conf \ httpd. conf and add the following content after the LoadModule added in step 2:
WSGIScriptAlias/E:/websiteProj/mysite/wsgi. py # Here is the wsgi. py file in the app.
WSGIPythonPath/path/to/mysite.com # directory of the project
<Directory/path/to/mysite.com/mysite>
<Files wsgi. py>
Require all granted
</Files>
</Directory>
Restart apache service and go to http: // localhost/website/(website is the app name). You can see that the app is already running. However, all static files are missing.
4. Open C: \ apache24 \ conf \ httpd. conf and add:
Alias/static/E:/websiteProj/mysite/website/static/
<Directory E:/websiteProj/mysite/website/static>
Require all granted
</Directory>
ReenterHttp: // localhost/website/. The static file is normally displayed. You can add files in the media folder to httpd. conf in the same way. Simply put, replace static with media.