安装Nginx

环境

Mac OS X 10.7.5 的操作系统

安装

使用自制软件进行安装

brew install nginx
==> Caveats
In the interest of allowing you to run `nginx` without `sudo`, the default
port is set to localhost:8080.

If you want to host pages on your local machine to the public, you should
change that to localhost:80, and run `sudo nginx`. You'll need to turn off
any other web servers running port 80, of course.

You can start nginx automatically on login running as your user with:
  mkdir -p ~/Library/LaunchAgents
  cp /usr/local/Cellar/nginx/1.2.7/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/
  launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist

Though note that if running as your user, the launch agent will fail if you
try to use a port below 1024 (such as http's default of 80.)

To have launchd start nginx at login:
    ln -sfv /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents
Then to load nginx now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist

WARNING: launchctl will fail when run under tmux.
Warning: /usr/local/sbin is not in your PATH
You can amend this by altering your ~/.bashrc file
==> Summary
 /usr/local/Cellar/nginx/1.2.7: 9 files, 892K, built in 12 seconds

启动服务器并进行操作确认

进行以下设定的测试

$ nginx -t -c /path/to/nginx.conf

如果结果成功,那就好。

启动服务器如下所示

$ nginx -c /path/to/nginx.conf

当然,在访问http://localhost:8080/后,如果能够看到Welcome页面,则表示一切顺利。

服务器停止

$ nginx -s stop

重新加载设置

$ nginx -s reload

设定

/usr/local/etc/nginx/nginx.conf 可以用以下的方式进行表达: “nginx的配置文件位于/usr/local/etc/nginx/nginx.conf”

使用指定的设定文件来启动

$ /usr/local/sbin/nginx -c /Users/nakamatsu(設定ファイルパス)

强烈推荐使用绝对路径来设定文件。

请参考

用Rails + Nginx + Unicorn进行安装 | ハコフグ
使用nginx + unicorn构建运行rails3.1的环境 – A Peak Never Ending!
Nakajijapan » 尝试搭建“Unicorn + Rails + Nginx”

广告
将在 10 秒后关闭
bannerAds