简体   繁体   English

无法在Ubuntu的导轨上运行ruby

[英]Not able to run ruby on rails on ubuntu

I have installed ruby on rails using the below tutorial https://gorails.com/setup/ubuntu/14.10 .I completed all the steps mentioned as per the tutorial and I could even create a rails app and run it using rails server . 我使用下面的教程https://gorails.com/setup/ubuntu/14.10在ruby上安装了ruby。我完成了教程中提到的所有步骤,甚至可以创建rails应用程序并使用rails server运行它。

When I used rails server , it showed me 当我使用rails server ,它显示了我

ubuntu@ip-192-30-0-97:~/myapp$ rails server
=> Booting WEBrick
=> Rails 4.2.0 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-02-01 09:45:51] INFO  WEBrick 1.3.1
[2015-02-01 09:45:51] INFO  ruby 2.1.5 (2014-11-13) [x86_64-linux]
[2015-02-01 09:45:51] INFO  WEBrick::HTTPServer#start: pid=11899 port=3000

But when I navigate to my IP (Elastic IP pointing to my instance running Ubuntu 14.04),Im just getting a page "Website not available" .I could get this working on my local computer,when I navigated to the localhost IP the rails default page opened up,however here Im not able to get this working. 但是,当我导航到我的IP(指向运行Ubuntu 14.04的实例的弹性IP)时,我只是得到一个“网站不可用”页面。当我导航到localhost IP时,我可以在本地计算机上运行它页面打开了,但是在这里我无法正常工作。

I am new to RoR and ubuntu,please help on this. 我是RoR和ubuntu的新手,请提供帮助。


As of rails 4.2, rails s by default only binds to the localhost interface. 从rails 4.2开始, rails s默认情况下仅绑定到localhost接口。 To bind to other interfaces use the - b option, for example 要绑定到其他接口,请使用- b选项,例如

rails s -b 0.0.0.0

restores the behaviour of earlier rails versions. 恢复早期Rails版本的行为。 You'll still need to configure security group rules and any firewall running on the instance to allow incoming connections. 您仍然需要配置安全组规则和在实例上运行的所有防火墙以允许传入连接。

Usually one wouldn't use webrick for a production deployment though 通常,虽然不会将Webrick用于生产部署

The webrick server seems to be running properly. webrick服务器似乎运行正常。 You need to go to: 您需要转到:

http://ipaddress:3000

And you should see the rails default page. 并且您应该看到rails默认页面。

You can also try running webrick on port 80 like this: 您也可以尝试在端口80上运行webrick,如下所示:

rails s -p 80

And then simply accessing it with http://ipaddress 然后只需使用http://ipaddress访问

This is considering port 3000 or 80 are open on your server. 这是考虑到服务器上的端口3000或80已打开。 If you are using Amazon EC2, check out their documentation: 如果您使用的是Amazon EC2,请查看其文档:

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/authorizing-access-to-an-instance.html http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/authorizing-access-to-an-instance.html

Here is the easiest way to install rvm, rails and ruby in one command only. 这是仅通过一个命令安装rvm,rails和ruby的最简单方法。 Run

\\curl -sSL https://get.rvm.io | \\ curl -sSL https://get.rvm.io | bash -s stable --rails bash -s稳定--rails

in terminal. 在终端。 It's going to reject you first time, you have to import the key, just c/p the line above, it actually says you to do that. 它将第一次拒绝您,您必须导入密钥,只需c / p上面的行,它实际上说您可以这样做。 Then run the curl command again and voila, you have working rails environment. 然后再次运行curl命令,瞧,您已经在Rails环境下工作了。 Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM