3

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

1
  • 1
    I feel like this is more a question for your Web host. Commented Sep 8, 2014 at 6:13

1 Answer 1

1

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; 
}
Sign up to request clarification or add additional context in comments.

2 Comments

@Rixh Peck What is passenger? is it useful for this?
Passenger is the Rails' preferred hosting system. I'm not sure how it works exactly - I just know it's truly amazing! You can see it by looking up Phusion Passenger - you'll have to ensure you set it up with your webhost first

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.