Php and rails on one linux server hosting

I'm new to hosting services

I have a domain for ex www.example.com which works in php so in public_html I put all php files

I have support for multiple hosts (which support ruby ​​on rails, php, etc.)

so i want to create a subdomain 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 app folders, etc. inside a sub but when we got the link sub.ecample.com or ecample.com/sub it is just showing the directory listing

Please help i am not sure if any configurations are needed etc. to run rails

* If this post is marked as duplicate or deleted etc. please help in links as comments I have not found links for help / questions etc.

+3


source to share


1 answer


As mentioned, the fix for this would be to talk to your web host directly.

However, to give you a clearer idea of ​​what to do, you have several important options:


Server software

The first and most important step is to make sure you have the correct server software installed, or at least it points to your domain correctly.

I'm not sure how the hosting provider will handle this, but the typical way to set up a VPS / "self-service" system is to use one of the popular open source applications; usually Apache or Nginx.

If you use either of these (as I'm sure it's the same with the other server flavors), the setup allows you to provide "virtual hosts". This gives you the ability to host multiple websites on the same server.

Without going into too much detail (you'd better ask your host about this), you'll want to look at these resources:



All of these guidelines will help you install one of the open source apps, which will give you the ability to route different subdomains / requests to the respective apps you have.


Public

Second, you must properly consider the importance of routing to your Rails application.

Rails applications are not like PHP - they are real applications, that is, they run on your localized system, taking input from the HTTP protocol. The way you can enter the "Rails Console" is because the application runs on your local ruby ​​installation, accepting any requests from the "server" that Rails can then handle.

The problem is if you just head to the Rails root directory that won't download the files correctly. If you want the application to load as needed, you must point your web server to the directory /public

.

I'm not sure how Rails manages this, but every time you submit a request to the application, it will observe the directory public

, which will then send the request to your Rails server. In short, you need to go to the folder /public

:

#etc/nginx/nginx.conf
server { 
  listen 80; 
  server_name example.com; 
  passenger_enabled on; 
  root /var/www/my_awesome_rails_app/public; 
}

      

+1


source







All Articles