1

I have Apache server with installed PHP by default. There are several applications working on PHP, and I'm going to run there applications on Rails also.

  1. If I install also Ruby and Rails, may applications on PHP somehow interfere the applications on Rails?
  2. In Rails tutorial there is a command '>rails server' to run the server. If I already use the server for applications on PHP, should I use that command? If so, what would it do?

My appreciation for response.

1 Answers1

1
  1. A server like Apache handles requests. If you make a request to a php program, then the php program will execute. If you make a request to a ruby program (i.e. a rails program), then the ruby program will execute. Typically, you will add a shebang line to a ruby program:

    #!/usr/bin/env ruby
    

    so that the server knows to use ruby to execute the program.

  2. $ rails server starts the WEBrick server, which is a ruby server and has nothing to do with Apache.

7stud
  • 46,922
  • 14
  • 101
  • 127
  • Thanks. But as I understood from this installation guide https://nathanhoad.net/how-to-ruby-on-rails-ubuntu-apache-with-passenger it's talking about installation on Apache ( No WEBrick ) About my second question. What that command actually does? In case of PHP applications there is nothing similar to that. –  Aug 03 '16 at 18:55
  • @SonyaSeyrios, the command `$rails server` starts the ruby WEBrick sever, which listens on port 3000 for requests, so if you enter a url like: `http://localhost:3000/users/` that will be handled by the WEBrick server. On the other hand, your Apache server will probably be setup to listen on port 8000 or 8080 for requests, so if you enter a url like `http://localhost:8000/users/`, then Apache will handle that request. You don't want to start the WEBrick server if you aren't going to use it. Instead, start your Apache server however you do it, then enter urls in your browser. – 7stud Aug 03 '16 at 19:07
  • @SonyaSeyrios, Both WEBrick and Apache are computer programs. They are both servers. You can use which ever one you want. Both have certain commands that you have to issue to start the sever. – 7stud Aug 03 '16 at 19:13
  • To conclude: 1. It's possible to install Rails on Apache (not WEBrick), as described in sent link. Subsequently, it will listen to 8000/8080 port, as PHP. 2. If I do like that, I may not use the command >rails server, as Apache already works. Please correct if I'm wrong. –  Aug 03 '16 at 19:14
  • Right. You don't want to start the ruby WEBrick server--using the command `rails server`--if you are not going to use that server. – 7stud Aug 03 '16 at 19:16
  • @SonyaSeyrios, If you were confused by my use of `WEBrick` as the name of the server that `rails server` starts--it looks like `rails server` now starts a server named `Puma`. – 7stud Aug 03 '16 at 19:21
  • Thanks. And finally, which option do you prefer? Use one server for both PHP and Rails, or use WEBrick for Rails? –  Aug 03 '16 at 19:21
  • @SonyaSeyrios, If you are just learning Rails and following the Rails tutorial, I would stick with whatever they use. I have apache+php installed, and I've never used apache for rails development. I just use `rails sever` to start the server, then I look at the server output to see what url/port I need to enter into my browser. It's much easier to use `rails server`. – 7stud Aug 03 '16 at 19:25
  • Yes, I'm reading "Agile web development on Rails". Here is what confused me: " Maybe you’ve been following along and writing the code in this chapter. If so, chances are that the application is still running on your computer. When we start coding our next application in ten pages or so, we’ll get a conflict the first time we run it, because it will also try to use the computer’s port 3000 to talk with the browser. Now would be a good time to stop the current application by pressing Ctrl-C in the window you used to start it. ". Comments? –  Aug 03 '16 at 19:33
  • What if I have several applications? –  Aug 03 '16 at 19:39
  • @SonyaSeyrios, See here: http://stackoverflow.com/questions/1694144/can-two-applications-listen-to-the-same-port – 7stud Aug 04 '16 at 18:52