开发者

redirect to a subdomain in rails 3

开发者 https://www.devze.com 2023-02-12 20:57 出处:网络
I just set up my rails 3 on Amazon EC2 with apache2 and passenger. Everything is working great but when I created my first project inside

I just set up my rails 3 on Amazon EC2 with apache2 and passenger.

Everything is working great but when I created my first project inside /var/www/html/ror/public/ the project does not show up. I tried mydomain.com/example which is the name of my project and it gives me an index of my rails project that I generated earlier. When I say index I mean a list of all the folders without rendering any html from the views. I guess my question is: how do I redirect the user to mydomain.com/example/app/views/example/index.html.erb

I tried playing around with httpd.conf and 开发者_运维技巧but nothing seems to work out.

Thanks


You are facing problems in deploying the site. Follow this -

  1. Create a virtual host

    $ sudo nano /etc/apache2/sites-available/app-name

  2. Change the contents of the virtual host to

    <VirtualHost *:80>  
        ServerName  A.B.C.D  
        ServerAlias subdomain.abc.com  
        DocumentRoot /var/www/app-name/current/public
        RackEnv production
    </VirtualHost>
    
  3. Enable the new site

    $ sudo a2ensite demo-app

  4. Restart Apache

    $ sudo /etc/init.d/apache2 restart

Make sure you mention the correct document root.

DocumentRoot /var/www/app-name/current/public

More details - https://docs.google.com/document/d/1Cw-oiE4AYrnbo_b7o593npTPaW8hRhRZERJ_ZETdrB8/edit?hl=en


You need to add RailsBaseURI /ror/public to your apache config.

Or, symlink:

mkdir /var/rails
mv /var/www/html/ror /var/rails
cd /var/www/html
ln -s /var/www/html/ror/public ror

(shouldn't put Rails app sources in your apache document tree)

and then RailsBaseURI /ror

Your app will be at example.com/ror

0

精彩评论

暂无评论...
验证码 换一张
取 消