首页 > 代码库 > Apache:To Config The Vhost of Django Project

Apache:To Config The Vhost of Django Project

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(via)

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 included 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 (via)

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