我一定要我的Apache服务器来运行脚本上安装Ruby [英] Do I have to install Ruby on my Apache server to run scripts

查看:138
本文介绍了我一定要我的Apache服务器来运行脚本上安装Ruby的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在我的笔记本我的脚本。因此,它是必要对Apache网络服务器安装Ruby运行它还是有其他的可能性?

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?

非常感谢!

推荐答案

您可以大概笔记本直接运行该脚本。

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

这应该打印:

hello

您可以运行任何Ruby code的方式。

You can run any Ruby code that way.

您也可以使脚本可执行。

You can also make the script executable.

编辑example.rb所以它读起来就像这样:

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

然后运行它:

 ./example.rb

如果您正在构建的东西更像一个Rails应用程序,并且要在运行Apache的远程web服务器运行:

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


  1. 在远程Web服务器,您必须安装Ruby。我个人比较喜欢 红宝石安装 好过 rbenv RVM

安装Web应用程序服务器。我个人比较喜欢的Apache 客运

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

配置Apache。乘客宝石会告诉你如何做到这一点。

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

重新启动Apache。

Restart Apache.

这篇关于我一定要我的Apache服务器来运行脚本上安装Ruby的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆