From 6c15bfcc76af1cfbae6c000a8adb29852e50d413 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Thu, 11 Apr 2013 12:38:16 -0400 Subject: [PATCH] Make nginx more convenient; clean up caveats No shin, screw that. Make nginx use a sensible docroot. All web servers should use this docroot from now on. I suggest the symlink method to making them do this so it is easy for people to change this on a server-by-server basis and have multiple docroots. --- Formula/nginx.rb | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/Formula/nginx.rb b/Formula/nginx.rb index ce4dcc77fbe..28e0e20e5bc 100644 --- a/Formula/nginx.rb +++ b/Formula/nginx.rb @@ -45,6 +45,7 @@ class Nginx < Formula "--with-http_ssl_module", "--with-pcre", "--with-ipv6", + "--sbin-path=#{bin}/nginx", "--with-cc-opt=-I#{HOMEBREW_PREFIX}/include", "--with-ld-opt=-L#{HOMEBREW_PREFIX}/lib", "--conf-path=#{etc}/nginx/nginx.conf", @@ -54,7 +55,9 @@ class Nginx < Formula "--http-proxy-temp-path=#{var}/run/nginx/proxy_temp", "--http-fastcgi-temp-path=#{var}/run/nginx/fastcgi_temp", "--http-uwsgi-temp-path=#{var}/run/nginx/uwsgi_temp", - "--http-scgi-temp-path=#{var}/run/nginx/scgi_temp"] + "--http-scgi-temp-path=#{var}/run/nginx/scgi_temp", + "--http-log-path=#{var}/log/nginx" + ] args << passenger_config_args if build.include? 'with-passenger' args << "--with-http_dav_module" if build.include? 'with-webdav' @@ -69,23 +72,29 @@ class Nginx < Formula system "make install" man8.install "objs/nginx.8" (var/'run/nginx').mkpath + + prefix.cd do + dst = HOMEBREW_PREFIX/"var/www" + if not dst.exist? + mv "html", dst + dst.dirname.mkdir_p + else + rm_rf "html" + dst.mkpath + end + Pathname.new("#{prefix}/html").make_relative_symlink(dst) + end end def caveats; <<-EOS.undent - In the interest of allowing you to run `nginx` without `sudo`, the default - port is set to localhost:8080. + Docroot is: #{HOMEBREW_PREFIX}/var/www - 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. + The default port has been set to 8080 so that nginx can run without sudo. - You can start nginx automatically on login running as your user with: - mkdir -p ~/Library/LaunchAgents - cp #{plist_path} ~/Library/LaunchAgents/ - launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename} + If you want to host pages on your local machine to the wider network you + can change the port to 80 in: #{HOMEBREW_PREFIX}/etc/nginx/nginx.conf - 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.) + You will then need to run nginx as root: `sudo nginx`. EOS end