The MOD_WSGI modules for the apache2 and apache2 need to be installed, and the Apache2 installation configuration is omitted.
Easy to install under Ubuntu system
sudo Install Libapache2-mod-wsgi
If it is Python3, install libapache2-mod-wsgi-py3
The version that Django uses is 1.8.2, and the wsgi.py file is automatically generated in the project directory after the project is established. A bit of manual modification, after modification:
1 Import OS2 Import SYS3 From django.core.wsgi import get_wsgi_application4 5Project_dir = Os.path.dirname(Os.path.dirname(__file__))6 ifProject_dir notinchSys.path:7Sys.path.insert (0, Project_dir)8Os.environ.setdefault ("Django_settings_module","site5.settings")9application = Get_wsgi_application ()
Next, in the /etc/apache2/sites-available/ directory, create a site configuration file, for example, named site.conf content as follows:
1<virtualhost *: the>2 ServerName site.me3 Serveralias www.site.me4ServerAdmin [email protected]163. com5 6<Directory/home/td/Django/site5>7 Require All granted8</Directory>9 TenWsgiscriptalias//home/td/django/site5/site5/wsgi.py One A<Directory/home/td/Django/site5/site5> -<files wsgi.py> - Require All granted the</Files> -</Directory> -</VirtualHost>
Add a line of content to the/etc/hosts and set
127.0. 0.1 Site.me
Finally, the relevant settings for Apache2
1 sudo A2ensite site.conf 2 sudo service apache2 Reload
Next, enter site.me in the browser address bar to see the pages of the Django site
Apache2 Deploying a Django Web site