How to host a rails web application
EDIT
It has been pointed out to me that a link in my answer does no longer work. Which is not that surprising, since this is a 3 year old answer.
Because It seems like people are still stumbling on this answer, I would like to redirect people to this page:
https://gorails.com/deploy/ubuntu/16.04
It should have all the information you need to deploy a rails application.
End EDIT
I recommend that you check out
http://rubyonrails.org/deploy
to start with.
And also
http://www.cloudfoundry.com/
and
https://www.engineyard.com/
are both great hosts for any rails application, and they also have some pretty easy to follow step-by-step tutorials on how to do so.
As Leito mentioned Heroku in his answer, I would like to point you to
http://www.codeschool.com/code_tv/heroku
If you choose Heroku as your host, you could check out that video as it shows you how to deploy a simple rails application.
How do you host a Ruby on Rails application on a local network, so multiple people can access it?
- Since you're on Windows, open up a command line and run
ipconfig
to find out your local IP. It will be listed under 'IP Address'. - Tell people in your LAN to access http://192.168.x.x:3000 replacing 192.168.x.x by your IP address from step 1.
Uploading Rails to a website
You should write Capistrano script for deployment. This is recommended way at present for deployment Rails applications to remote servers.
But this is not a one way to do it. So, you can use other approaches i.e. build and deploy Docker containers or copy sources over FTP manually (this is not recommended but possible way).
How can I host my API and web app on the same domain?
Usually you don't expose such web applications directly to clients. Instead you use a proxy server, that forwards all incoming requests to the node or rails server.
nginx is a popular choice for that. The beginners guide even contains a very similar example to what you're trying to do.
You could achieve what you want with a config similar to this:
server {
location /api/ {
proxy_pass http://localhost:8000;
}
location / {
proxy_pass http://localhost:3000;
}
}
This is assuming your API runs locally on port 8000 and your express app on port 3000. Also this is not a full configuration file - this needs to be loaded in or added to the http
block. Start with the default config of your distro.
When there are multiple location entries nginx chooses the most specific one. You could even add further entries, e.g. to serve static content.
How to deploy rails 3 app using parallels Plesk?
There appears to be some threads out there on this:
- forum.parallels.com/
- kb.parallels.com/en/5489
Resolution
As of version 8.1, Plesk Control Panel supports Ruby on Rails. There is not an option in the Plesk Control Panel that should be checked to enable Ruby on Rails support; you only need to install the ruby packages.
To install an application written in Ruby, take the following steps:
- Go to Domains > your-domain.com > Setup.
- Select the CGI and FastCGI check-boxes and click OK.
- Connect to your FTP account, change to the
/htdocs directory
, and create a subdirectory where the application files will reside. Let's call this directory your_application, for illustration purposes. - Upload the application files to the
htdocs/your_application
directory. - Create a file with the name .htaccess in this directory, open it with a text editor of your choice, and add the following lines into the file:
RewriteEngine On
RewriteRule ^$ /public/index.html [L]
RewriteCond %{REQUEST_URI} !^/your_application/public
RewriteRule ^(.*)$ /public/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ public/dispatch.fcgi/$1 [QSA,L]
- Save the file.
- Remove the
your_application/public/.htaccess
file. - Open the your_application/public/dispatch.fcgi file with a text editor and put the following lines there:
#!/usr/bin/ruby
- Save the file.
The web application will now be accessible at the following URL:http://your-domain.com/your_application
Related Topics
Ruby on Rails HTML-Table Generator
Disable Devise's :Confirmable On-The-Fly to Batch-Generate Users
Heroku Won't Reset My Database
Rails Render Partial in Helper
Error Connecting to Redis on 127.0.0.1:6379 (Errno::Econnrefused) - Wercker
Carrierwave Cannot Remove Image
Count Records Created Within the Last 7 Days
Capturing Logger Output Inside a Method
Best Practice for Limiting the Number of Associations Within a Has_Many Relationship
Ruby (With Rails) Convert a String of Time into Seconds
Invoking Knife in a Ruby Class
Thin Doesn't Respond to Sigint or Sigterm
Gem And/Or Ruby on Rails Broke All of a Sudden, Anyone Know What Happened
Retrieve All Posts Where the Given User Has Commented, Ruby on Rails
Why Are My Thread Variables Intermittent in Rails
How to Specify a Minimum Ruby Version in a Gemspec