Playing with nginx + passenger for Ubuntu Server/ Mac OSX

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/

https://www.digitalocean.com/community/tutorials/how-to-install-rails-and-nginx-with-passenger-on-ubuntu

http://blog.sina.com.cn/s/blog_4a9569ce0101fnio.html

https://ruby-china.org/wiki/mac-nginx-passenger-rails

前往 Medium.com 檢視

https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html#install_osx_homebrew

(for osx yosemite ,install brew before install nginx+passenger)

http://brew.sh/

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

https://www.ihash.eu/2014/10/edit-hosts-file-mac-os-x-10-10-yosemite/

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)

http://osxdaily.com/2014/11/20/flush-dns-cache-mac-os-x/

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

https://ruby-china.org/topics/19510