https://ihower.tw/rails4/installation.html
https://ihower.tw/rails4/deployment.html
http://www.robertmulley.com/tutorial/nginx-install-and-setup-mac-os-x-yosemite/
http://blog.sina.com.cn/s/blog_4a9569ce0101fnio.html
https://ruby-china.org/wiki/mac-nginx-passenger-rails
https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html#install_osx_homebrew
(for osx yosemite ,install brew before install nginx+passenger)
After install nginx+passenger , you will see this in command line
Docroot is: /usr/local/var/www
The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.
nginx will load all files in /usr/local/etc/nginx/servers/.
To activate Phusion Passenger, add this to /usr/local/etc/nginx/nginx.conf, inside the ‘http’ context:
passenger_root /usr/local/opt/passenger/libexec/lib/phusion_passenger/locations.ini;
passenger_ruby /usr/bin/ruby;
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
Or, if you don’t want/need launchctl, you can just run:
nginx
1)sudo nginx //start service , see localhost:8080 or localhost:80 will show “welcome to nginx
2) edit the /opt/nginx/conf/nginx.conf
add
server{
listen 80;
server_name app_name.dev;
root /home/www/rails_project/public #point to your rail project public folder’s location
passenger_enabled on; #for rails project
passenger_app_env development; #it your project still in development setting
}
//if you need more domain name in localhost…
https://www.digitalocean.com/community/questions/can-we-host-multiple-websites-in-nginx-at-localhost
Edit your /etc/hosts file and add the following line: 127.0.0.1 app1.dev app2.dev etc.dev; You should be able to access your apps by browsing to http://app_name.dev
(if using yosemite , flush dns cache)
forbbiden 403
try add index.html (with “<html>hello world</html>")in public folder, if web browser can access, it means you write a wrong root in nginx.conf