I am developing a Rails 3 application and I have installed Capistrano on the client side and Passenger with Apache 2 on the server side.
I make a deployment and the files are sent to a folder called u/apps/.
But when I visit the IP address I am currently using I only get to an empty folder, how do I configure Apache to look for my app in the current folder? So that I only need to visit my IP/domain to see my app?
I have done this using Rails 2.x but I think for Rails 3 also pretty much the same thing. For this you need to use Passenger and then configure Apache.
Following are some useful resources
http://www.modrails.com/install.html
http://railscasts.com/episodes/122-passenger-in-development
If you browse to your URL and you see an apache files/folders list that means that passenger is not triggered for that location...
Test your server environment by running a mongrel/thin in your application folder and see that your application runs correctly. After that, look at your Apache configuration (see Passenger docs).
Related
My issue is that I created a droplet to develop Rails apps in digitalocean .
I used the one-click rails droplet. And now I want to create more rails apps than the default rails app in this droplet.
The issue here is that it comes installed with nginx/unicorn .. And they're always on with path of default rails project in their config files.
Now let's assume I created another rails app(file) and I want to run it using "rails s" instead of default rails app that is created by the droplet. How can I do it?
Note: I don't want to change the file path in configs each time I decide to try another app
PS: I tried stopping the service of unicorn/nginx one at a time and both of them in the same time to use "rail s" to run the app .. But it didn't work .. Web pages were not loading
I know it might be a question of a rookie. But I'm kinda new to these stuff and I'd appreciate it if anyone could help me.
If you run it with rails s on the server, chances are it will be running with Puma, or if you're on an older version of Rails, Webrick. Unicorn is not involved in that case because Rails is using its own default web server. If you see that 'rails s' is not running in the right environment, it may be because RAILS_ENV is being set in your shell profile. You can override that by doing:
RAILS_ENV=development rails s
To launch your console.
That being said, rails s runs on localhost:3000 by default - and in the case you described it would be running on DigitalOcean's localhost - not yours. In order to get to it from your local machine, you would need to set up some sort of reverse proxy to allow connections to DO to get served from localhost. This is what nginx is doing for you - it's facilitating a reverse proxy.
If you want do use your DO server as a development machine for a second rails app you have, you're going to have to create that new rails app on the server, then create the reverse proxy settings in nginx to direct to it, then finally create the unicorn settings to serve it. This is an uncommon way of developing though. I recommend using your local machine to develop, and setting up Capistrano or some other deploy tool to deploy it to DO instead. You'd still need to add the settings in nginx/unicorn for the second app, but it will save you headache down the road.
I'm able to run rails s through ssh successfully and see the app start up just as it does on my own machine but I'm unable to access the app from the web. The app is directly under the home folder and I have a symbolic link pointing from public_html to the public folder of my rails app, just as this tutorial explains. I even tried setting up a subdomain and every other step in the tutorial to no avail. Any help would be highly appreciated.
You need an application server like Phusion Passenger, Unicorn or puma to run a Ruby app in a production environment. Typically, you'll integrate the application server into a web server's (Apache, nginx) environment.
I don't know about your hoster, but if you have root access, then you can probably use any of these application servers.
The built-in server you start by running rails server is only meant for testing purposes on your local machine. It has not been made with security, performance, stability or any other production-environment criteria in mind.
I installed Ubuntu, GlassFish web server, installed JRuby on Rails using GlassFish's admin tools, deployed my application from .war archive. The problem is only - when I attempt to run this web application nothing happens. GlassFish isn't listening on port 8080 as promised. The GlassFish administration web console listens on port 4848 and works fine. What to do to pair GlassFish and JRuby on Rails the correct way, remembering that it isn't a separate JRuby installation?
Update: it seems that this problem lies somewhere around access rights because I can deploy an application through
sudo ./asadmin deploy
but can not do the same through web console. The output is as if the application has been deployed, without any error messages (web interface shows the presence of application, domain folder contains my application's file/folder structure), but something in server's internals isn't bound to application.
I didn't think much and applied quick and dirty solution: set "777" access rights to /home/glassfish and all its contents. It helped.
I've been trying to set up a web server using EC2 on Amazon web services.
Using the appstack-nginx-passenger-ree AMI, I tried to set up the server.
I put my ruby files in /opt/sites and I installed passenger and apache2-dev & apace2-mpm-fork.
I had to set up the apache config file.
Afterwards what should I do?
How do I set the path file of the ruby files and deploy them?
How can I start up the server and be able to look at it?
You should make sure you start up apache (which should show you a default welcome page on your the IP of you box (if you have opened up the firewall)), then setup the path to your ruby project in your httpd.conf file.
Here's a guide that might help you out
Paul, your link is broken, the corrected link for the guide is this Setting up Rails 3 on Amazon EC2 instance
What should be the permission on rails app directory on apache server???
What is your deployment design?
Normally you'd use mongrels and apache as a load balancer for them.
So you'd run the mongrels as a user for your site, and all the rails directory should have permissions for that user.
You probably have a 'www' or 'apache' user that owns your static content and apache root document directory.
It's common convention to make this user own your rails app as well to preserve the same permissions.
If you use something like capistrano, I think it has builtin recipes for permission structure on top of your release directory after deploying.
As Angelus said, it depends on your server setup and deployment design. You can use mongrels (or thins, or unicorns, or...) with Apache as a reverse-proxy, but your question leads me to believe you're using Phusion Passenger (aka mod_rails).
If that's the case, the mod_rails site has several very helpful screencasts which you should watch. Generally, though, mod_rails will run as whichever user owns your app's environment.rb file. See the Passenger user switching docs for details on your permission setup.
While installing apache it creates www-data group and owner so you have to give the ownership of this user for your application.
Then restart the apache service.
rails application works fine.