Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails on Apache on Windows - HOWTO

This question has not been asked since Rail 3.0 came out (or I cannot find it):

How to run Rails 3+ application on Apache on Windows (WAMP)? Is Mongrel the best option? Sounds not optimal to me to have Apache as a proxy and then another server. Passenger does not exist on Windows.

What I hope to get from your is a link to a magical installation package and a snippet from the httpd.conf file that would divert one to a rails application.

like image 616
zmilojko Avatar asked Dec 23 '25 02:12

zmilojko


1 Answers

The advantage of using apache (or nginx) as a proxy is that it can load-balance between different mongrel (or thin) instances. So you would have to start three mongrel instances (services) and configure apache to proxy those.

Configuring apache to different mongrel processes is pretty straightforward, can be found all over the internet. Here is an example of a httpd-vhosts.conf (replace yourapplication by your actual application/domain and root-folder):

<VirtualHost *:80>
    #ServerName 10.200.65.35
    #ServerAlias 10.200.65.35
    ServerName yourapplication.com

    DocumentRoot d:/yourapplication/current/

    <Directory c:/yourapplication/current/public/ >
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      allow from all
    </Directory>


     # On active les proxy qui sont par défaut désactivés
    <Proxy *>
        Order allow,deny
        Allow from all
    </Proxy>
    <Proxy balancer://mongrel_cluster>
        BalancerMember http://127.0.0.1:4000
        BalancerMember http://127.0.0.1:4001
        BalancerMember http://127.0.0.1:4002
    </Proxy>

    ProxyPass / Balancer://mongrel_cluster/
    ProxyPassReverse / balancer://mongrel_cluster/
    #ProxyReserveHost on


    #log files
    ErrorLog "/Program Files/Apache Software Foundation/Apache2.2/logs/yourapplication_error.log"
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
    CustomLog "/Program Files/Apache Software Foundation/Apache2.2/logs/yourapplication_access.log" combined

    #Rewrite stuff
    RewriteEngine On

    # Rewrite index to check for static
    RewriteRule ^/$ /index.html [QSA] 

    # Rewrite to check for Rails cached page
    RewriteRule ^([^.]+)$ $1.html [QSA]

    # Redirect all non-static requests to cluster
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
    RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]
</VirtualHost>

Another, very promising alternative to deploy on windows is using TorqueBox. TorqueBox is JBoss/Jruby based solution, and thus platform independent. In benchmarks it is shown that TorqueBox performs incredibly well, and actually anybody should seriously consider switching to it.

Hope this helps.

like image 134
nathanvda Avatar answered Dec 24 '25 18:12

nathanvda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!