Reputation: 517
I am new to hosting services
i have a domain for ex www.example.com which is running in php so in public_html i have put all php files
i have multi hosting support(which support ruby on rails ,php etc)
so i want to create a sub domain in ruby on rails
for ex: sub.ecample.com which should point to public_html/sub
i tried rails new sub from ssh(putty) it created application folders etc inside sub but when we got to link sub.ecample.com or ecample.com/sub its just showing directory list
Please help i am not sure if any configurations etc is needed to run rails
*If this post is marked as duplicate or any deleted etc please provide helping links as comments i didnt find any helping links/questions etc
Upvotes: 3
Views: 732
Reputation: 76774
As mentioned, the fix for this will be to talk with your web host specifically.
However, to give you a clearer picture of what to do, you have several important options:
Server Software
The first, and most important, step is to ensure you have the right server software installed, or at least have it pointing to your sub domain correctly
I'm not sure how a shared hosting provider will handle this, but the typical way for a VPS / "self hosted" system to be set up is to use one of the popular open source server applications; typically Apache or Nginx.
If you use either of these (as I am sure is the same with the other server variants out there), the setup permits you the provision for "virtual hosts". These give you the ability to host multiple websites on a single server
Without going into too much detail (you'll be best enquiring with your host about it), you'll want to look at these resources:
All of these will advise you to install one of the open source server applications, which will give you the ability to then route the different subdomains / requests to the respective applications you have.
Public
Secondly, you have to consider the importance of routing to your Rails application correctly.
Rails applications are not like PHP - they are real applications, meaning they run on your localized system, accepting input from the HTTP protocol. That's how you can go into the "Rails Console" - because the application runs on your local ruby installation, taking any requests from the "server", which Rails can then process.
The problem you have is that if you're just routing to the Rails "root" directory, which won't load the files correctly. If you want the application to load as required, you have to point your web server to the /public
directory.
I'm not sure how Rails manages this, but every time you send a request to the application, it will observe the public
directory, which will then send the request through to your Rails backend. In short, you need to route to your /public
folder:
#etc/nginx/nginx.conf
server {
listen 80;
server_name example.com;
passenger_enabled on;
root /var/www/my_awesome_rails_app/public;
}
Upvotes: 1