My First Django Project (3)-Apache set up

Source: Internet
Author: User

Holy moly!!!! Because I missed a slash, I repeatedly debug 2, 3 days, unable to read the static file, has not been able to find the reason, and later in the Apache Error.log found the reason.

1. Download Apache 2.4 and install Mod_wsgi:: http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi

Basically third-party packages can be found at this address.

WHL file: You can use the install PIP *.WHL to extract the installation, unzip the folder you are in, there will be a mod_wsgi.so file, bake it in: {Install Directory}\apache24\modules

Apache Installation and configuration is relatively simple, the only notable is that after the installation of the configuration {install directory}\apache24\conf\httpd.conf file.

is Define srvroot "{}" remember to change to the directory where you Apache24. Also note the use and modification of ports, such as 80 ports, may thunderbolt and IIS will occupy, modify the port number,

12.34. 56.78:  127.0.  0.1:8086     here for change to Port 8086

2. The next step is to configure Django and Apache

or {install directory}\apache24\conf\httpd.conf This file, you need to set the road strength and the like

#添加mod_wsgi. So module LoadModule wsgi_module modules/mod_wsgi.so #指定myweb项目的wsgi. py configuration file path Wsgiscriptalias/f:/django_project/qblog/qblog/wsgi.py #指定项目路径 wsgipythonpath F:/django_project/Qblog<directory f:/django_project/qblog/qblog> <files wsgi.py>Require All granted</Files> </Directory>Alias/static/F:/django_project/qblog/static/ #The red part especially pay attention ah, before is here is the pit father, online to the tutorial most no last / cause my static file read not come out<directory F:/django_project/qblog/static/ ># do remember to add/, the last is to see the Apache errorlog only found, sure enough to see the log is very useful! allowoverride None Options none Require all granted</Directory>

setting.py Remember to set DEBUG and template_debug to True, otherwise there will be 404 error.

DEBUG = True= true= []

3. admin static file display incorrect condition

Set Static_root in setting.py first

" Static ")  

Then run collectstatic to collect all the static files under Static_root (including the admin and your app's static files)

F:\mydjango>python manage.py collectstatic  

Then point your static road to here! Done!

My First Django Project (3)-Apache set up

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.