Apache and rails - ruby-on-rails

guys.
OK. Trying to deploy a rails project on apache. Ive deleted the public/index.html file. I cant get past the "It works!" screen. Im guessing this is a routing issue - Ive got to give it the right document root so that it can find the homepage of the app I have created, right? Problem is, Ive tried everything - anything outside of the public folder doesnt seem to exist. Here is my apache sites-available file:
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot /home/feenix/public_html/CRRC/public
</VirtualHost>
I changed the rails root to "home#index". Ive tried that as a document root for apache and it doesnt recognise it. Any help would be appreciated, as to where I should be looking for the correct document root - do I have to add something to the public folder in the rails project? Any help will be gratefully appreciated.
Cheers

It works! is the Apache default. That means you aren't pointing properly at Rails yet.
You've got the DocumentRoot correct.
Do you have NameVirtualHosts *:80 setup? Also, is Passenger enabled? I'm assuming you're using it.

Related

How to change the configuration file to deploy a rails app with apache? on a subdomain

I was given an url http://XXXXXX.XXXX.XXX/avrccalendar/
and was asked to deploy my rails app on it.
At the beginning, there was a static webpage index.html in the /www directory, which is nothing but a message and was deleted by me.
This is my first time to deploy a rails app and I set my .conf like this:
VirtualHost *:80>
ServerName XXXXXX.XXXX.XXX/avrccalendar
DocumentRoot /home/avrccalendar/calendar/public
RailsEnv production
/VirtualHost>
I set it up that way, because I think rails app creates dynamic content, thus I didn't put the app files in the /www directory. However, when I visit the website it still get the static webpage index.html.
I cannot find whers the configuration is that set the url to return that static webpage.
And i would like to know how I should set .conf to make it to visite my rails app.
I have already installed passenger. The environment is Ubuntu 14.04.
Any advice would be helpful. Thank you~!

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

Ruby on Rails app in root directory?

Hey guys, new to rails, but I have found out how to create an app now through the shell but to create an app using rails appname would give me a url of http://url.com/appname/ but I want my app, to be within the route if you understand me, so it's just http://url.com/login/ or /signup or /play so on?
So does anyone have any ideas how to do this, or why you can't or I shouldn't? Anything really, thanks guys!
if you use passenger and apache, firstly in your apache conf file
<VirtualHost *:80>
ServerName myapp.local
DocumentRoot "/home/davit/myapp/public"
</VirtualHost>
DocumentRoot should be point to your app' s public folder.
And in public folder create a .htaccess file and write this:
PassengerEnabled on
RailsEnv development
Rails application is stored in some directory like appname but it doesn't appear in url path. In general you should configure your server (Apache, nginx, ...) to point to public folder in rails application. The only thing to do is to configure your server properly.
It depends on your hosting provider, with dreamhost, which I use, its part of the tools they provide to configure where do I want the application to be.
If you have to configure things yourself, you can still write your alias configuration or whatever your server uses to map to your rails application public/ folder.

How can mod_perl and Passenger run on the same Apache server?

Is this even possible?
I have a Rails app running on Passenger and a mod_perl site that need to run on the same server. I've tried setting up two VirtualHosts and I've tried just using one VH and an Alias/Location for the mod_perl. In both cases, Passenger tries to serve the mod_perl app and tells me it can't find the correct files. Anyone know what I'm doing wrong?
Here's my setup atm:
NameVirtualHost *:80
RailsAutoDetect off
<VirtualHost *:80>
DocumentRoot (home of rails app)/public
RailsBaseURI /
</VirtualHost>
PerlModule Apache::DBI
PerlRequire /opt/rt3/bin/webmux.pl
Alias /rt /opt/rt3/share/html <== mod_perl app
<Location /rt>
AddDefaultCharset UTF-8
SetHandler perl-script
PerlHandler RT::Mason
</Location>
Well, for right now I've just set them up as two different VirtualHosts using different ports to connect. That works, but it's a little messy for my site to use and if anyone has a better idea, I'm all ears. Thanks.
Edit: Got it working! I ended up setting up two VirtualServers on different ports, then used mod-proxy to redirect traffic to the /rt site to the mod-perl VirtualServer (leaving the Passenger one as the default). This works great, and best of all my mod_perl site believes it's still in the same place as Passenger, which smooths out a lot of compatibility issues I was dealing with as well. I knew I was missing something simple! Just putting this up in case anyone else is having issues with this.

Resources