一台服务器上设置几个Django的应用 [英] Setting up several Django apps on one server
问题描述
我一直在试图配置两个单独的Django的一台服务器上的哪些应用,使得它们可以在不同的URL使用下面的配置,我可以访问第一个应用程序来访问......,但是我处于亏损如何包括第二个应用程序的安装。管理媒体也没有被加载在所有
I've been trying to configure two separate Django apps on one server such that they can be accessed at different URL's...using the below config, I can access the first app, but I'm at a loss at how to include the setup for the second app. The admin media is also not being loaded at all
NameVirtualHost *:8032
服务器名本地主机
SERVERADMIN webmaster@example.com
ServerName localhost ServerAdmin webmaster@example.com
DocumentRoot "/usr/local/www/djcode/test"
<Directory "/usr/local/www/djcode/test">
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
Alias /site_media "/usr/local/www/djcode/test/site_media/"
Alias /media "/usr/local/www/djcode/test/site_media/media/"
WSGIDaemonProcess test user=www group=www processes=2 threads=5
WSGIProcessGroup test
AddHandler wsgi-script .wsgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /test.wsgi/$1 [QSA,L]
服务器名本地主机
ServerAlias本地主机
的DocumentRoot在/ usr /本地/网络/ apache22 /数据
ServerName localhost ServerAlias localhost DocumentRoot "/usr/local/www/apache22/data"
推荐答案
请在/ etc / apache2的/网站的可用文件夹两个配置文件。根据你的网站给他们适当的逻辑名称(例如example1.com,example12.com等)。使用a2ensite命令,以使他们与重新启动Apache服务器。
Make two configuration files in /etc/apache2/sites-available folder. Give them proper logical names according to your sites (e.g. example1.com , example12.com etc). Use a2ensite command to enable both of them and restart your apache server.
每个你的配置文件应该是这个样子:
Each of your config file should look something like this:
<Virtualhost *:8032>
ServerName localhost
ServerAdmin webmaster@example.com
DocumentRoot "/usr/local/www/djcode/test"
<Directory "/usr/local/www/djcode/test">
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
Alias /site_media "/usr/local/www/djcode/test/site_media/"
Alias /media "/usr/local/www/djcode/test/site_media/media/"
WSGIDaemonProcess test user=www group=www processes=2 threads=5
WSGIProcessGroup test
AddHandler wsgi-script .wsgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /test.wsgi/$1 [QSA,L]
</Virtualhost *:8032>
您还需要添加一些指令,以提供静态内容。来自Apache提供静态内容有开销,因此就如使用一些轻量级的Web服务器,如lighttpd的或Nginx的连接和使用反向代理服务Django的基于内容部署到Apache服务器,你是它一个更好的主意。 这里有一个教程使用nginx的
You'll also need to add up some directives to serve static content. Serving static content from apache has overhead so it'll be a better idea if you server it using some lightweight webserver such as Lighttpd or Nginx and connect to apache using reverse proxy to serve the django based content. Here's a tutorial on using NginX
由于您使用mod_wsgi的,可以让他们两个不能访问彼此的数据运行的每个站点不同的用户也是如此。如果两个站点属于不同的利益相关者,这非常有用。
Since you are using mod_wsgi, you can run each site as different user as well so that two of them may not access each other's data. This is useful if the two sites belong to different stakeholders.
这篇关于一台服务器上设置几个Django的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!