











Ref:
http://wiki.jmoiron.net/MigratingFromApacheToNginx
http://turbogears.org/2.0/docs/main/Deployment/modwsgi+virtualenv.html
http://wiki.nginx.org/NginxConfiguration
Req:
Debian os, python2.5, apache2, libapache2-mod-wsgi
Nginx is designed to do best to serve static files and proxying request to it's actual processor, so our deployment will use nginx as a front end, actually act as a web server, also do some load balance job; apache act as a application server role in our deployment, we don't use the mod_wsgi(atually apache-mod_wsgi,not that nginx's patch) in a embeded mode, which code executed in the apache's worker process and cause apache do much work that it shouldn't, daemon mode is like FastCGI and apache proxying task to other worker process, like wsgi handers.
#/etc/apache2/ports.conf
NameVirtualHost *:8119
Listen 8119
NameVirtualHost
*:8120#Apache configuration File
#Read README.txt
#1. This file should be added to your apache config folder; On Debian copy to /etc/apache2/sites-available/
#Default location for tg2 project is /usr/local/turbogears/myapp. That is where you should put your project. This folder should be outside of apache location. Your package should not be installed into python site-package.
#2. Alias/Allow apache to serve static content.
#Alias /myapp/images /usr/local/turbogears/myapp/myapp/public/images
#Alias /myapp/css /usr/local/turbogears/myapp/myapp/public/css
#Alias /myapp/javascript /usr/local/turbogears/myapp/myapp/public/javascript
#Embeded mode (http://example.com/myapp).For big websites with a lot of memory and visitors.
#WSGIScriptAlias /myapp /usr/local/turbogears/myapp/apache/myapp.wsgi
#3. Test if modwsgi is working. Uncomment below line, and go to http://localhost/test:
#WSGIScriptAlias /test /usr/local/turbogears/myapp/apache/test.wsgi
#4. [Optional] Sitewide (http://example.com/)
#Alias /images /usr/local/turbogears/myapp/myapp/public/images
#Alias /css /usr/local/turbogears/myapp/myapp/public/css
#Alias /javascript /usr/local/turbogears/myapp/myapp/public/javascript
#WSGIScriptAlias / /usr/local/turbogears/apache/myapp.wsgi
#5. [Optional] Deamon mode with 10 threads and 3 processes. For small to medium website.
#WSGIDaemonProcess myapp threads=10 processes=3
#WSGIProcessGroup myapp
#WSGIScriptAlias / /usr/local/turbogears/myapp/apache/myapp.wsgi
#6. Directory Permission.
<Directory /usr/local/turbogears/myapp/apache>
Order deny,allow
Allow from all
</Directory>#7. [Optional] If you want to use Virtualhost apache settings.
#Sample Virtual Host configuration would look like this:
<Directory /usr/local/turbogears/myapp/apache>
Order allow,deny
Allow from all
</Directory>
NameVirtualHost
*:8119NameVirtualHost
*:8120#user nobody;
worker_processes 1;#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections
http {
include mime.types;
default_type application
server {
listen
$ /etc/init.d/apache2 restart
$ nginx -t -c /etc/nginx/nginx.conf
$ nginx -c /etc/nginx/nginx.conf &
#open browser to browse the http://your_debian_host/ check your deploment
this is very simple config, for the production enviroment, you should check the more doc to get the best suit for you.
We get the perfectly 3-tiers infrastructure for our n-tiers-oriented application, but it compares to the nginx+nginx-mod_wsgi style may has little speed limitation, no benchmark data now, maybe someone can do a test to get the actual performance data.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。