Because Django comes with a lightweight server, this server is used by default in the previous blog post, but is not allowed in real production, and is typically used in production environments with Apache HTTPD server combined with mod_wsgi.so for back-end servers. The following deployment environments are: Python2.7.61, installing HTTPD-2.2.25-WIN32-X86-NO_SSL.MSI2, placing downloaded mod_wsgi.so in D:\Program files\apache software Under the Foundation\apache2.2\modules module. 3, in the new Web project Mydjangoproject directory under the new Django.wsgi file content as follows (the corresponding directory needs to be modified):
1 2 ImportOS3 ImportSYS4 5Djangopath ="D:/python27/lib/site-packages/django/bin"6 ifDjangopath not inchSys.path:7 sys.path.append (Djangopath)8 9ProjectPath ='D:/workspace/mydjangoproject'Ten ifProjectPath not inchSys.path: One sys.path.append (ProjectPath) A -AppPath ='D:/workspace/mydjangoproject/mydjangoproject' - ifAppPath not inchSys.path: the sys.path.append (AppPath) -os.environ['Django_settings_module']='mydjangoproject.settings' - - fromDjango.core.wsgiImportget_wsgi_application +application = Get_wsgi_application ()
4, modify the httpd.conf, add the following:
1LoadModule Wsgi_module modules/mod_wsgi.so2Wsgiscriptalias/"D:/workspace/mydjangoproject/django.wsgi"3<directory"d:/workspace/mydjangoproject/">4 Options followsymlinks5 allowoverride None6 Order Deny,allow7Allow from All8</Directory>
OK, restart the server, the page is OK. During the deployment process, an exception was encountered, as follows:
1 is ready
The reason is that django.wsgi at the beginning according to the older wording, the new version of the wording is OK.
Python & pycharm & Django Build Web Development environment (cont.)