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-06-05 15:22:47 +00:00
|
|
|
url 'http://nginx.org/download/nginx-1.2.1.tar.gz'
|
2012-06-06 00:05:22 +00:00
|
|
|
sha1 '4fb69411f6c3ebb5818005955a085e891e77b2d8'
|
2009-09-01 20:23:31 +00:00
|
|
|
|
2012-05-16 10:28:43 +00:00
|
|
|
devel do
|
2012-06-26 15:16:56 +00:00
|
|
|
url 'http://nginx.org/download/nginx-1.3.2.tar.gz'
|
|
|
|
sha1 'a3507cb2f13332489804f79885541c717f8f4bf0'
|
2012-05-16 10:28:43 +00:00
|
|
|
end
|
|
|
|
|
2010-07-09 06:06:29 +00:00
|
|
|
depends_on 'pcre'
|
2010-07-08 17:03:02 +00:00
|
|
|
|
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
|
|
|
|
|
2009-09-23 13:23:48 +00:00
|
|
|
def options
|
|
|
|
[
|
2011-01-27 02:34:27 +00:00
|
|
|
['--with-passenger', "Compile with support for Phusion Passenger module"],
|
|
|
|
['--with-webdav', "Compile with support for WebDAV module"]
|
2009-09-23 13:23:48 +00:00
|
|
|
]
|
|
|
|
end
|
2010-06-22 21:27:22 +00:00
|
|
|
|
2010-02-01 18:48:01 +00:00
|
|
|
def passenger_config_args
|
|
|
|
passenger_root = `passenger-config --root`.chomp
|
2010-06-22 21:27:22 +00:00
|
|
|
|
2010-02-01 18:48:01 +00:00
|
|
|
if File.directory?(passenger_root)
|
|
|
|
return "--add-module=#{passenger_root}/ext/nginx"
|
|
|
|
end
|
2010-06-22 21:27:22 +00:00
|
|
|
|
2010-02-01 18:48:01 +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
|
|
|
|
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-04-07 00:14:47 +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",
|
2010-07-12 04:13:26 +00:00
|
|
|
"--lock-path=#{var}/nginx/nginx.lock"]
|
2011-03-27 21:18:36 +00:00
|
|
|
|
2010-06-25 17:06:33 +00:00
|
|
|
args << passenger_config_args if ARGV.include? '--with-passenger'
|
2011-01-27 02:34:27 +00:00
|
|
|
args << "--with-http_dav_module" if ARGV.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"
|
2010-09-01 21:07:45 +00:00
|
|
|
|
2011-12-31 05:56:52 +00:00
|
|
|
plist_path.write startup_plist
|
|
|
|
plist_path.chmod 0644
|
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;
|