Do I have to install Ruby on my Apache server to run scripts

一世执手 提交于 2019-12-13 02:38:19

问题


I just have my script on my notebook. So is it necessary to install ruby on apache webserver to run it or are there other possibilities?

Thanks a lot!


回答1:


You can probably run the script on your notebook directly.

Try creating an example script like this:

echo "puts 'hello'" > example.rb
ruby example.rb

That should print:

hello

You can run any Ruby code that way.

You can also make the script executable.

Edit example.rb so it reads like this:

 #!/usr/bin/env ruby
 puts 'hello'

Then on the command line, make the script executable:

 chmod +x example.rb

Then run it:

 ./example.rb

If you are building something more like a Rails app, and you want to run it on a remote webserver that runs Apache:

  1. On the remote webserver, you must install Ruby. I personally like ruby-install better than rbenv and rvm.

  2. Install a web application server. I personally like Passenger for Apache.

  3. Configure Apache. The Passenger gem will tell you how to do this.

  4. Restart Apache.



来源:https://stackoverflow.com/questions/27099612/do-i-have-to-install-ruby-on-my-apache-server-to-run-scripts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!