2009-10-15 08:07:12 +00:00
|
|
|
require 'formula'
|
2009-09-01 20:23:31 +00:00
|
|
|
|
2009-09-23 06:58:03 +00:00
|
|
|
class Nginx < Formula
|
2010-04-30 15:57:12 +00:00
|
|
|
homepage 'http://nginx.org/'
|
2012-09-25 14:11:52 +00:00
|
|
|
url 'http://nginx.org/download/nginx-1.2.4.tar.gz'
|
|
|
|
sha1 'e3de0b2b82095f26e96bdb461ba36472d3e7cdda'
|
2009-09-01 20:23:31 +00:00
|
|
|
|
2012-05-16 10:28:43 +00:00
|
|
|
devel do
|
2012-11-03 16:52:53 +00:00
|
|
|
url 'http://nginx.org/download/nginx-1.3.8.tar.gz'
|
|
|
|
sha1 '84ff39e3f76e9f496f4e05080885e04caf472bb9'
|
2012-05-16 10:28:43 +00:00
|
|
|
end
|
|
|
|
|
2012-09-14 16:07:47 +00:00
|
|
|
env :userpaths
|
|
|
|
|
2010-07-09 06:06:29 +00:00
|
|
|
depends_on 'pcre'
|
2010-07-08 17:03:02 +00:00
|
|
|
|
2012-08-13 21:04:47 +00:00
|
|
|
option 'with-passenger', 'Compile with support for Phusion Passenger module'
|
|
|
|
option 'with-webdav', 'Compile with support for WebDAV module'
|
|
|
|
|
2010-02-01 18:48:01 +00:00
|
|
|
skip_clean 'logs'
|
2009-10-03 09:00:44 +00:00
|
|
|
|
2011-06-05 20:32:01 +00:00
|
|
|
# Changes default port to 8080
|
2009-10-03 09:00:44 +00:00
|
|
|
def patches
|
|
|
|
DATA
|
|
|
|
end
|
|
|
|
|
2010-02-01 18:48:01 +00:00
|
|
|
def passenger_config_args
|
2012-09-29 12:41:21 +00:00
|
|
|
passenger_root = `passenger-config --root`.chomp
|
2010-06-22 21:27:22 +00:00
|
|
|
|
2012-09-29 12:41:21 +00:00
|
|
|
if File.directory?(passenger_root)
|
|
|
|
return "--add-module=#{passenger_root}/ext/nginx"
|
|
|
|
end
|
2010-06-22 21:27:22 +00:00
|
|
|
|
2012-09-29 12:41:21 +00:00
|
|
|
puts "Unable to install nginx with passenger support. The passenger"
|
|
|
|
puts "gem must be installed and passenger-config must be in your path"
|
|
|
|
puts "in order to continue."
|
|
|
|
exit
|
2010-02-01 18:48:01 +00:00
|
|
|
end
|
2010-06-22 21:27:22 +00:00
|
|
|
|
2009-09-01 20:23:31 +00:00
|
|
|
def install
|
2011-03-27 21:18:36 +00:00
|
|
|
args = ["--prefix=#{prefix}",
|
|
|
|
"--with-http_ssl_module",
|
|
|
|
"--with-pcre",
|
2012-06-22 10:59:36 +00:00
|
|
|
"--with-ipv6",
|
2012-07-19 23:41:45 +00:00
|
|
|
"--with-cc-opt=-I#{HOMEBREW_PREFIX}/include",
|
|
|
|
"--with-ld-opt=-L#{HOMEBREW_PREFIX}/lib",
|
2011-03-27 21:18:36 +00:00
|
|
|
"--conf-path=#{etc}/nginx/nginx.conf",
|
|
|
|
"--pid-path=#{var}/run/nginx.pid",
|
2012-09-29 12:41:21 +00:00
|
|
|
"--lock-path=#{var}/run/nginx.lock",
|
|
|
|
"--http-client-body-temp-path=#{var}/run/nginx/client_body_temp",
|
|
|
|
"--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"]
|
2011-03-27 21:18:36 +00:00
|
|
|
|
2012-08-13 21:04:47 +00:00
|
|
|
args << passenger_config_args if build.include? 'with-passenger'
|
|
|
|
args << "--with-http_dav_module" if build.include? 'with-webdav'
|
2010-06-22 21:27:22 +00:00
|
|
|
|
2010-06-25 17:06:33 +00:00
|
|
|
system "./configure", *args
|
2011-10-11 17:40:40 +00:00
|
|
|
system "make"
|
2009-09-01 20:23:31 +00:00
|
|
|
system "make install"
|
2011-10-11 17:40:40 +00:00
|
|
|
man8.install "objs/nginx.8"
|
2012-09-29 12:41:21 +00:00
|
|
|
(var/'run/nginx').mkpath
|
2009-12-14 06:16:24 +00:00
|
|
|
end
|
2010-06-22 21:27:22 +00:00
|
|
|
|
2011-06-05 20:32:01 +00:00
|
|
|
def caveats; <<-EOS.undent
|
|
|
|
In the interest of allowing you to run `nginx` without `sudo`, the default
|
|
|
|
port is set to localhost:8080.
|
2010-02-01 18:48:01 +00:00
|
|
|
|
2011-06-05 20:32:01 +00:00
|
|
|
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.
|
2010-09-01 21:07:45 +00:00
|
|
|
|
2011-06-05 20:32:01 +00:00
|
|
|
You can start nginx automatically on login running as your user with:
|
|
|
|
mkdir -p ~/Library/LaunchAgents
|
2011-12-31 05:56:52 +00:00
|
|
|
cp #{plist_path} ~/Library/LaunchAgents/
|
|
|
|
launchctl load -w ~/Library/LaunchAgents/#{plist_path.basename}
|
2010-09-01 21:07:45 +00:00
|
|
|
|
2011-06-05 20:32:01 +00:00
|
|
|
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.)
|
|
|
|
EOS
|
2009-12-14 06:16:24 +00:00
|
|
|
end
|
2010-09-01 21:07:45 +00:00
|
|
|
|
|
|
|
def startup_plist
|
|
|
|
return <<-EOPLIST
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
|
|
<plist version="1.0">
|
|
|
|
<dict>
|
|
|
|
<key>Label</key>
|
2011-12-31 05:56:52 +00:00
|
|
|
<string>#{plist_name}</string>
|
2010-09-01 21:07:45 +00:00
|
|
|
<key>RunAtLoad</key>
|
|
|
|
<true/>
|
|
|
|
<key>KeepAlive</key>
|
2012-06-20 05:29:13 +00:00
|
|
|
<false/>
|
2010-09-01 21:07:45 +00:00
|
|
|
<key>UserName</key>
|
|
|
|
<string>#{`whoami`.chomp}</string>
|
|
|
|
<key>ProgramArguments</key>
|
|
|
|
<array>
|
2011-12-31 22:13:31 +00:00
|
|
|
<string>#{HOMEBREW_PREFIX}/sbin/nginx</string>
|
2010-09-01 21:07:45 +00:00
|
|
|
</array>
|
|
|
|
<key>WorkingDirectory</key>
|
|
|
|
<string>#{HOMEBREW_PREFIX}</string>
|
|
|
|
</dict>
|
|
|
|
</plist>
|
|
|
|
EOPLIST
|
|
|
|
end
|
2009-09-01 20:23:31 +00:00
|
|
|
end
|
2009-10-03 09:00:44 +00:00
|
|
|
|
|
|
|
__END__
|
2009-12-14 06:16:24 +00:00
|
|
|
--- a/conf/nginx.conf
|
|
|
|
+++ b/conf/nginx.conf
|
|
|
|
@@ -33,7 +33,7 @@
|
|
|
|
#gzip on;
|
2010-06-22 21:27:22 +00:00
|
|
|
|
2009-12-14 06:16:24 +00:00
|
|
|
server {
|
|
|
|
- listen 80;
|
|
|
|
+ listen 8080;
|
|
|
|
server_name localhost;
|
2010-06-22 21:27:22 +00:00
|
|
|
|
2009-12-14 06:16:24 +00:00
|
|
|
#charset koi8-r;
|