ubuntu下快速配置mongrel+apache2
ubuntu下用源装好 apache2,它的配置是比较特殊的,但熟悉了之后还是好配的。apache2的配置文件主要是在/etc/apache2下,要用root权限。
先要起用mod,办法很简单,用ln 把mods-available下的模块链接到 mods-enabled下就可以起用了。
至少需要以下模块:
proxy_balancer.loadproxy.loadproxy_http.load
在mods-enabled目录下使用:
sudo ln -s ../mods-available/proxy.load proxy.load
这样就创建了软链接。
然后要创建一个站点,假设域名叫webcs,可以在/etc/hosts里定义一下:
127.0.0.1 webcs
然后在/etc/apache2/sites-available下创建一个文件webcs,输入:
ProxyRequests Off <Proxy balancer://mongrel_cluster> BalancerMember http://127.0.0.1:8000 BalancerMember http://127.0.0.1:8001 BalancerMember http://127.0.0.1:8002 </Proxy><VirtualHost *> ServerName webcsProxyPass /images ! ProxyPass /stylesheets ! ProxyPass /javascripts ! ProxyPass /stylesheets ! ProxyPass /yui ! ProxyPass /enter_chat.html ! ProxyPass /license.html ! ProxyPass /favicon.ico ! Alias /images /home/magicgod/workspace/webcs/public/imagesAlias /stylesheets /home/magicgod/workspace/webcs/public/stylesheetsAlias /javascripts /home/magicgod/workspace/webcs/public/javascriptsAlias /yui /home/magicgod/workspace/webcs/public/yuiAlias /enter_chat.html /home/magicgod/workspace/webcs/public/enter_chat.htmlAlias /license.html /home/magicgod/workspace/webcs/public/license.htmlAlias /favicon.ico /home/magicgod/workspace/webcs/public/favicon.ico ProxyPass / balancer://mongrel_cluster/ ProxyPassReverse / balancer://mongrel_cluster/ ProxyPreserveHost onErrorLog /var/log/apache2/webcs-error_logCustomLog /var/log/apache2/webcs-access_log common</VirtualHost>
假设开了三个mongrel,并且端口从8000开始增加排列。
日志目录要指向/var/log/apache2,可以参考另一个站点配置default,在ubuntu里会缺省创建这个站点。
静态内容都不要传到mongrel去,直接建立别名,也可以仅仅用DocumentRoot指向。一定要用ProxyPass来禁止转换。
保存后在sites-enabled目录创建一个软链接:
sudo ln -s ../sites-available/webcs 001-webcs
再重新启动一下apache2
页:
[1]