参考文章:http://www.jrrzz.net/2010/01/10/multi-host-trac-using-nginx/
我觉得多实例运行的关键点在于对 fastcgi中的script_name和path_info的理解
script_name是脚本名称,我们可以理解成应用的一个入口
path_name是传给这个入口的一个参数,是一个路径
比如在php中
http://www.test.com/index.php/foo/bar.html?c=index&m=search
这里的/index.php为script_name
/foo/bar.html为path_info
再后面的就为query_string鸟
在我们这里如果我们想这样运行多实例
http://xxx.com/trac/instance1/wiki
http://xxx.com/trac/instance2/wiki
就是使用这样的方式在运行instance1和instance2这两个trac的项目实例
那么我们就得设置/trac/instancex(x为可变的部分)为script_name
而后面的为path_info
比如这里的/wiki即为path_info

理解这点我们不难理解下面的配置文件了.
这里很欣赏nginx的配置文件的语法,弄的和脚本语言似的,有正则,有判断,有赋值
PS:为了彻底弄清楚fastcgi_split_path_info这个指令的工作原理,还去看了下nginx的源码,还好有c语言的功底.
这个没有文档的东东还真不容易找一些想知道的东西,除了看源码.
--------------------------------------------
回复
回推
New Retweet
收藏
from Echofon2010-04-16 09:37:16
回复
回推
New Retweet
收藏
from Echofon2010-04-16 09:50:26
回复
回推
New Retweet
收藏
from Echofon2010-04-16 09:51:47
----------------------------------------------------
下面是nginx的配置文件
user admin;
worker_processes 5;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location ~ ^/trac/([0-9a-zA-Z\-]*)/chrome(.*)$ {
alias /home/admin/trac/$1/htdocs$2;
}
fastcgi_split_path_info ^(/trac/[0-9a-zA-Z\-_]*[/]*)(.*)$;
location ~ /htdocs/(.*){
root /home/admin/trac;
}
if ($uri ~ ^/trac/([0-9a-zA-Z\-_]*).*$) {
set $trac_host $1;
}
location ~ ^/trac/([0-9a-zA-Z\-]*)/login {
auth_basic "trac";
auth_basic_user_file /home/admin/etc/trac_$trac_host.htpasswd;
fastcgi_pass unix:/home/admin/run/trac_fastcgi_$trac_host.sock;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param AUTH_USER $remote_user;
fastcgi_param SCRIPT_NAME /trac/$trac_host;
fastcgi_param PATH_INFO /$fastcgi_path_info;
fastcgi_param REMOTE_ADDR $remote_addr;
}
location ~ ^/trac {
auth_basic "trac";
fastcgi_pass unix:/home/admin/run/trac_fastcgi_$trac_host.sock;
fastcgi_param SCRIPT_NAME /trac/$trac_host;
fastcgi_param PATH_INFO /$fastcgi_path_info;
## WSGI NEEDED VARIABLES - trac warns about them
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param AUTH_USER $remote_user;
fastcgi_param REMOTE_ADDR $remote_addr;
#root html;
#index index.html index.htm;
}
location = / {
index index.html
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}

- 大小: 51 KB
分享到:
相关推荐
1. 使用pip安装Trac:打开终端或命令提示符,输入`pip install trac`。这将自动下载并安装Trac及其依赖项。 2. 安装数据库驱动:根据您选择的数据库类型,安装相应的Python数据库驱动。例如,对于SQLite,Python自带...
1. **环境准备**:确保你的服务器或本地机器上已经安装了Python(通常需要2.7或3.x版本,具体依赖Trac的版本)和一个数据库系统,如SQLite、MySQL或PostgreSQL。同时,还需要安装相关的Python库,例如`setuptools`、...
6. **配置Web服务器**:将Trac作为Apache或Nginx的模块,配置适当的反向代理规则。 7. **启动Trac服务**:根据Web服务器的设置启动或重启服务。 ### 配置Trac 1. **编辑配置文件**:Trac环境的配置文件是`conf/...
python学习资源
jfinal-undertow 用于开发、部署由 jfinal 开发的 web 项目
基于Andorid的音乐播放器项目设计(国外开源)实现源码,主要针对计算机相关专业的正在做毕设的学生和需要项目实战练习的学习者,也可作为课程设计、期末大作业。
python学习资源
python学习资源
python学习一些项目和资源
【毕业设计】java-springboot+vue家具销售平台实现源码(完整前后端+mysql+说明文档+LunW).zip
HTML+CSS+JavaScarip开发的前端网页源代码
python学习资源
【毕业设计】java-springboot-vue健身房信息管理系统源码(完整前后端+mysql+说明文档+LunW).zip
成绩管理系统C/Go。大学生期末小作业,指针实现,C语言版本(ANSI C)和Go语言版本
1_基于大数据的智能菜品个性化推荐与点餐系统的设计与实现.docx
【毕业设计】java-springboot-vue交流互动平台实现源码(完整前后端+mysql+说明文档+LunW).zip
内容概要:本文主要探讨了在高并发情况下如何设计并优化火车票秒杀系统,确保系统的高性能与稳定性。通过对比分析三种库存管理模式(下单减库存、支付减库存、预扣库存),强调了预扣库存结合本地缓存及远程Redis统一库存的优势,同时介绍了如何利用Nginx的加权轮询策略、MQ消息队列异步处理等方式降低系统压力,保障交易完整性和数据一致性,防止超卖现象。 适用人群:具有一定互联网应用开发经验的研发人员和技术管理人员。 使用场景及目标:适用于电商、票务等行业需要处理大量瞬时并发请求的业务场景。其目标在于通过合理的架构规划,实现在高峰期保持平台的稳定运行,保证用户体验的同时最大化销售额。 其他说明:文中提及的技术细节如Epoll I/O多路复用模型以及分布式系统中的容错措施等内容,对于深入理解大规模并发系统的构建有着重要指导意义。
基于 OpenCV 和 PyTorch 的深度车牌识别
【毕业设计-java】springboot-vue教学资料管理系统实现源码(完整前后端+mysql+说明文档+LunW).zip
此数据集包含有关出租车行程的详细信息,包括乘客人数、行程距离、付款类型、车费金额和行程时长。它可用于各种数据分析和机器学习应用程序,例如票价预测和乘车模式分析。