Running Ruby app on Apache

前端 未结 1 1150
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-22 23:56

I have been learning Ruby lately, and I want to upload a test web application to my server. But I can\'t figure out how to get it to run on my shared hosting.

My

相关标签:
1条回答
  • 2021-01-23 00:34

    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 /

    0 讨论(0)
提交回复
热议问题