redirect to a subdomain in rails 3 - ruby-on-rails

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 -
Create a virtual host
$ sudo nano /etc/apache2/sites-available/app-name
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>
Enable the new site
$ sudo a2ensite demo-app
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

Related

Ror app not running on CentOS

I am using CentOS 6.6 first time to deploy Rails 4 application. I have installed all necessary softwares like MySQL, Ruby, Rails, Passenger, Apache2, etc. I have tested it for index.html page inside /var/www/html/index.html and set it on Apache configuration and working perfect.
When I deployed Rails application it did run on the server but it displayed as shown in screenshot below.
Below are my Apache configuration settings which I have done so far.
/etc/httpd/conf/httpd.conf
LoadModule passenger_module /home/user/.rvm/gems/ruby-2.1.2/gems/passenger-5.0.6/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
PassengerDefaultRuby /home/user/.rvm/wrappers/ruby-2.1.2/ruby
PassengerRoot /home/user/.rvm/gems/ruby-2.1.2/gems/passenger-5.0.6
</IfModule>
I have created a file vhost.conf inside /etc/httpd/conf.d/
<VirtualHost *:80>
ServerName myipaddress
DocumentRoot /var/www/html/projectname/public_html/current/public
<Directory /var/www/html/projectname/public_html/current/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
# Uncomment this if you're on Apache >= 2.4:
#Require all granted
</Directory>
I run the command below command
service httpd restart
service httpd reload
Neither Rails app running in server nor showing any erros.
Any solution would be appreciated. Thanks in advance.
First and always check the Apache logs. This step is essential, but often overlooked. If that doesn't help, I would try a few things:
Double-check the documentation and make sure you've completely installed Passenger, and haven't skipped a step.
Start by removing the IfModule directive. Since you want Passenger, you want an error message if it isn't loading.
LoadModule passenger_module /home/user/.rvm/gems/ruby-2.1.2/gems/passenger-5.0.6/buildout/apache2/mod_passenger.so
PassengerDefaultRuby /home/user/.rvm/wrappers/ruby-2.1.2/ruby
PassengerRoot /home/user/.rvm/gems/ruby-2.1.2/gems/passenger-5.0.6
You have your IP address as your server name. Make sure this doesn't conflict with any other configurations (other sites, or httpd.conf). Otherwise, you may just be loading a different page / application.
Depending on how you have it set up, you may have permissions issues since you're pointing PassengerDefaultRuby and PassengerRoot to /home/user/.rvm. By convention, these are usually somewhere more public like /var/lib/gems/ and /usr/bin/.
Make sure you have defined a root path in your Rails application's config/routes.rb.
Make sure you've chown -R-ed your application path to the apache user. This will help you with troubleshooting and security.
After you've done all that, check the logs again. After you make a change, check the logs again.

Remove Bitnami Jenkins Access page

I have bitnami jenkins installed.
I have no problem with the url http://yourhost/jenkins but i need to delete the Bitnami Welcome page. is any idea?
The documentation (https://wiki.bitnami.com/Components/Bitnami_info_page) says that the bnconfig tool should be used. However for me this doesn't work and I changed it manually in the apache configuration files.
To do so, change in file /opt/bitnami/apache2/conf/bitnami/bitnami.conf the lines:
<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apache2/htdocs"
and
<VirtualHost _default_:443>
DocumentRoot "/opt/bitnami/apache2/htdocs"
into:
<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apps/jenkins/htdocs"
and
<VirtualHost _default_:443>
DocumentRoot "/opt/bitnami/apps/jenkins/htdocs"
Then restart apache:
sudo /opt/bitnami/ctlscript.sh restart apache
This si brutal but it works, and the vhost (http://yourhost/jenkins should also work) :)
Note that the main documentation (https://wiki.bitnami.com/Native_Installers_Quick_Start_Guide) says in part "How to change the default page that appears when accessing the installation?" that changing it manually is the way to go, but suggest to use a modified version of the main page. I guess this is fine if you have several apps installed.

Trouble deploying a Rails app (Linode, Passenger)

I'm a brand new Rails user, I'm following this tutorial- http://ruby.railstutorial.org/chapters/a-demo-app#top . Had no issues accessing the demo app (from Chapter 2) on the local server. However having issues deploying to my Linode server. Here's what I've done:
Push the local app to BitBucket
Clone the repo on Linode to: /srv/www/preziki/first_app
Bundle install
rake db:migrate
Update VirtualHost for preziki:
ServerAdmin oleg#preziki.com
ServerName preziki.com
ServerAlias www.preziki.com
DocumentRoot /srv/www/preziki/first_app/public
ErrorLog /srv/www/preziki/logs/error.log
CustomLog /srv/www/preziki/logs/access.log combined
a2ensite preziki
Restart apache
Reload apache
If I go to www.preziki.com (or 176.58.104.181), I see the default Rails "Welcome aboard" page. If you click the "About your application environment" link, you get the "Sorry but something went wrong" error. If I go to www.preziki.com/users, (like I could with localhost/users), I get teh "Sorry but something went wrong" error.
If I point VirtualHost to the dir where I have a "Hello world!" index.html file, then preziki.com displays it without a problem.
What am I doing wrong?
Thank you.
First thing you can see the "default Rails" environment, means check your web server(apache) is working fine. because its a static request.
Second things when you want to go into application environment, then their is a problem means your application is not deploy properly.
Few thing you need to check.
1. Give the application directory all permission.
2. bundle install properly
3. Set RailsENV in virtual host
4. rake db:migrate properly.
5. Check your log file what problem it is showing.
<VirtualHost *:80>
ServerName localhost
DocumentRoot /home/user/project/trunk/public
PassengerEnabled on
RailsEnv development
<Directory /home/user/project/trunk/public>
</Directory>
</VirtualHost>
It sounds like you're nearly there. My guess is that the app has a problem connecting to the database. But to see for yourself what the problem is, look in the production log file:
/srv/www/preziki/first_app/log/production.log
That will usually tell you everything you need to know. Another thing you can do to debug is to use the console on the server, in production mode:
bundle exec rails console production

When deploying a Rails 3 app with Capistrano 2.5.19, what should be in shared/system?

I am running Passenger with Apache2 on Ubuntu. I'm trying to get an idea what I should be looking at, and my suspicion lies with my Capistrano configuration / permissions.
My application seems to be deployed to current as expected. I can see all the project files. I see a symlink in the current/public directory to shared/system. When I look at the contents of shared/system, there is nothing, no symlink or files. Is this correct? Is a symlink missing?
Capistrano deployment file:
https://github.com/danieldbower/passhasher/blob/master/config/deploy.rb
Logged message in Apache:
Apache/2.2.16 (Ubuntu) Phusion_Passenger/3.0.2 mod_ssl/2.2.16 OpenSSL/0.9.8o configured -- resuming normal operations
Directory index forbidden by Options directive: /var/www/passhasher/
Apache Config:
Alias /passhasher /var/www-rails/passhasher/current/public
<Directory /var/www-rails/passhasher/current/public>
AllowOverride all
Options -MultiViews
</Directory>
This is the default folder in which you keep all files not related to a particular version of your deployment.
I put the users' uploads inside.
Have a look here:
http://blog.alastairdawson.com/2007/03/13/stop-uploaded-files-getting-deleted-with-capistrano/

Using mod_rails to host multiple apps under SSL, same domain

I'm trying to get multiple rails apps hosted under the same domain, but different directories. My configuration before attempting to host multiple apps (which works great), looks like this:
<VirtualHost *:443>
ServerName secure.mydomain.com
DocumentRoot /root/store/public
</VirtualHost>
I google'd around and found documentation suggesting I use the following configuration:
<VirtualHost *:443>
ServerName secure.mydomain.com
DocumentRoot /root
RailsBaseURI /store/public
RailsBaseURI /store2/public
</VirtualHost>
That configuration, however, only causes my directory structure to be revealed, and no app appears to run. Any advice would be great!
Not sure what you found on the Googles, but you might want to re-read the mod_rails docs on Deploying to sub URIs
I'm guessing you'll need to create some symbolic links (aliases) in your /root directory to the public folder of each application
ln -s /store/public /root/store

Resources