MacOS下Rails+Nginx+SSL环境的搭建(上)

这里把主要的步骤写下来,反正我是走了不少弯路,希望由此需求的朋友们别再走类似的弯路.虽说环境是在MacOS下搭建,但是基本上和linux下的很相像,大家可以举一反三.

一.安装Rails

这个是最简单的,大家可以到我blog看相关文章,安装完毕后创建一个rails项目,比如名字为rails_project,这时你启动rails服务器之后rails s,应该可以在浏览器中访问如下地址的页面:

http://localhost:3000

至此,Rails安装和后台服务都运行正常!

二.安装Passenger和Nginx

首先是gem中安装passenger包:

gem install passenger

敲入如下指令安装Nginx:

passenger-install-nginx-module

1.Yes: download, compile and install Nginx for me. (recommended) The easiest way to get started. A stock Nginx 1.0.10 with Passenger support, but with no other additional third party modules, will be installed for you to a directory of your choice.

2.No: I want to customize my Nginx installation. (for advanced users) Choose this if you want to compile Nginx with more third party modules besides Passenger, or if you need to pass additional options to Nginx's 'configure' script. This installer will 1) ask you for the location of the Nginx source code, 2) run the 'configure' script according to your instructions, and 3) run 'make install'.

在遇到以上选择的时候选择1,当询问Nginx安装路径的时候,建议安装到/usr/local/nginx下.

安装完毕后会在nginx的配置文件中(/usr/local/nginx/conf/nginx.conf)自动加入以下两行:

http { ... passenger_root /Users/Daniel/.rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.10; passenger_ruby /Users/Daniel/.rvm/wrappers/ruby-1.9.2-p290/ruby; ... }

server { listen 80; server_name www.yourhost.com; root /somewhere/public; # <--- be sure to point to 'public'! passenger_enabled on; }

这时你可以测试一下安装是否成功:

rvmsudo passenger-config validate-install
 * Checking whether this Phusion Passenger install is in PATH...* Checking whether there are no other Phusion Passenger installations...

如果你不是通过brew之类安装的nginx, 比如这里我们就不是,你要自己手动添加nginx到执行路径中去:

ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大熊猫侯佩

赏点钱让我买杯可乐好吗 ;)

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值