Running Ruby app on Apache

痴心易碎 提交于 2019-12-02 02:40:31

firstly you have to start your application manualy or by script when the server is starting. Just do something like ruby hi.rb (as described on sinatra webpage it runs appication on the port 4567). Then you have two options. 1) You can access this application directly as: http://yourserver:4567/ or 2) you can use apache as a proxy.

If you want use apache as a proxy you have to use virtualhost servers. for example:

NameVirtualHost hi.server:80
<VirtualHost hi.server:80>
    Servername hi.server
    RewriteEngine On
    <Proxy balancer://hi>
        BalancerMember http://127.0.0.1:4567
    </Proxy>
    ProxyPass / balancer://hi/
    ProxyPassReverse / balancer://hi/
</VirtualHost>

And if you have ie multiple cores you can run hi.rb more then once (each time on diferent port) and you just add new BalancerMember. You can also switch on apache cache using directive: CacheEnable mem /

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!