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/'
|
2011-06-04 20:52:58 +00:00
|
|
|
url 'http://nginx.org/download/nginx-1.0.4.tar.gz'
|
|
|
|
md5 'd23f6e6b07b57ac061e790b1ed64bb98'
|
2009-09-01 20:23:31 +00:00
|
|
|
|
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
|
|
|
|
# Tell configure to look for pcre in HOMEBREW_PREFIX
|
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",
|
|
|
|
"--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
|
2009-09-01 20:23:31 +00:00
|
|
|
system "make install"
|
2010-09-01 21:07:45 +00:00
|
|
|
|
2011-05-04 15:48:37 +00:00
|
|
|
(prefix+'org.nginx.nginx.plist').write startup_plist
|
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
|
|
|
|
cp #{prefix}/org.nginx.nginx.plist ~/Library/LaunchAgents/
|
|
|
|
launchctl load -w ~/Library/LaunchAgents/org.nginx.nginx.plist
|
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-05-04 15:48:37 +00:00
|
|
|
<string>org.nginx.nginx</string>
|
2010-09-01 21:07:45 +00:00
|
|
|
<key>RunAtLoad</key>
|
|
|
|
<true/>
|
|
|
|
<key>KeepAlive</key>
|
|
|
|
<true/>
|
|
|
|
<key>UserName</key>
|
|
|
|
<string>#{`whoami`.chomp}</string>
|
|
|
|
<key>ProgramArguments</key>
|
|
|
|
<array>
|
|
|
|
<string>#{sbin}/nginx</string>
|
|
|
|
<string>-g</string>
|
|
|
|
<string>daemon off;</string>
|
|
|
|
</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__
|
2010-07-09 06:06:29 +00:00
|
|
|
--- a/auto/lib/pcre/conf
|
|
|
|
+++ b/auto/lib/pcre/conf
|
|
|
|
@@ -155,6 +155,22 @@ else
|
|
|
|
. auto/feature
|
|
|
|
fi
|
2010-10-04 15:32:42 +00:00
|
|
|
|
2010-07-09 06:06:29 +00:00
|
|
|
+ if [ $ngx_found = no ]; then
|
|
|
|
+
|
|
|
|
+ # Homebrew
|
|
|
|
+ HOMEBREW_PREFIX=${NGX_PREFIX%Cellar*}
|
|
|
|
+ ngx_feature="PCRE library in ${HOMEBREW_PREFIX}"
|
|
|
|
+ ngx_feature_path="${HOMEBREW_PREFIX}/include"
|
|
|
|
+
|
|
|
|
+ if [ $NGX_RPATH = YES ]; then
|
|
|
|
+ ngx_feature_libs="-R${HOMEBREW_PREFIX}/lib -L${HOMEBREW_PREFIX}/lib -lpcre"
|
|
|
|
+ else
|
|
|
|
+ ngx_feature_libs="-L${HOMEBREW_PREFIX}/lib -lpcre"
|
|
|
|
+ fi
|
|
|
|
+
|
|
|
|
+ . auto/feature
|
|
|
|
+ fi
|
|
|
|
+
|
|
|
|
if [ $ngx_found = yes ]; then
|
|
|
|
CORE_DEPS="$CORE_DEPS $REGEX_DEPS"
|
|
|
|
CORE_SRCS="$CORE_SRCS $REGEX_SRCS"
|
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;
|