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.
This commit is contained in:
parent
2d6d3ea78a
commit
6c15bfcc76
1 changed files with 21 additions and 12 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue