Apache: To config the vhost of Django Project

Source: Internet
Author: User

It is not a good idea to use Dev server in production environment.

Apache or nginx are good choice. Both of them are of great used as the web server.

I'm trying to deploy in Apache.

 

The file Structre:

If you 've read djangoproject's documentation, you will find that my project's file structure is a bit different from what the documentation show ()

Both are OK.

Imagine that you have the Apache installed. And now, lets do it 1 by 1.

Step 1: edit the httpd. conf

/Path/to/The/Apache/CONF/thhpd. conf

Add a new line just at the end of the file. It seems to be looked like this:

The Windows Wamp version:

You need do nothing but just add this line in httpd. conf. I suggest you to do like that, because to config your apache_django project in a defined ded file will not break the protect the integrity of httpd. conf.

 

Step 2: Add mod_wsgi in to the modules path of Apache:

While the python gets a x86 and x64 version, and it is the same with the mod_wsgi

First, download the right version of mod_wsgi.for example, I have python2.7.x. amd64 and Apache 2.4.x installed in my PC (x64). So, I need to use ()

Uzip the package and you will get a mod_wsgi.so.

Put it in the Apache Modules

Step 3: edit the apache_django.conf and apache_django.wsgi

Apache_django.conf

PS. In this config file, I load the mod_wsgi module, config the vietual Python env

Listen the 8000 port which is used in my Django project and in the <virtualhost 127.0.0.1: 8000> ..... </Virtualhost> I config something of my project.

 

Apache_django.wsgi

In this file, I add the project into the python path so that Django driver can get the application

 

Step 4: CP the project files in to the www:

Seems like that:

Let's check into it

After all above, restart Apache server. Type http: // 127.0.0.1: 8000

Shit, what's happened?

Check in the Log Path no error found

Check httpd. conf:

Add this:

Check www root: Seems OK

OK, restart Apache:

Near to success!

Check in the error log:

.... No module ....... Orz ....

Apache_django.wsgi line 3

Maybe there's something wrong with my wsgipythonpath

Let's have a look at where the virtual env's site-packages are:

............................................ Orz...

Change it!

Restart apache service!

 

I give up...

Tomorrow will be OK

Time to sleep...

Apache: To config the vhost of Django Project

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.