DRYな備忘録

Don't Repeat Yourself.

どうせならローカル開発でもnginx使おうじゃないか【MacOSX10.9】【nginx】

Goal

Log

[11:20:29] → sudo apachectl stop
Password:

http://localhost にて、apache止まったことを確認

[11:20:40] → brew --version
0.9.5
[11:20:49] → brew search nginx
nginx

これね

[11:21:43] → brew install nginx
Warning: No developer tools installed.
You should install the Command Line Tools.
Run `xcode-select --install` to install them.
==> Installing nginx dependency: pcre
==> Downloading http://downloads.sourceforge.net/project/pcre/pcre/8.34/pcre-8.34.tar.bz2
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/pcre/8.34 --enable-utf8 --enable-unicode-properties --enable-pcregrep-libz --enable-pcregrep-libbz2 --enable-jit
==> make
==> make test
==> make install
🍺  /usr/local/Cellar/pcre/8.34: 140 files, 4.1M, built in 30 seconds
==> Installing nginx
==> Downloading http://nginx.org/download/nginx-1.4.4.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/nginx/1.4.4 --with-http_ssl_module --with-pcre --with-ipv6 --sbin-path=/usr/local/Cellar/nginx/1.4.4/bin/nginx --with-cc-opt=-I/usr/local/include --with-ld-opt=
==> make
==> make install
==> Caveats
Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that
nginx can run without sudo.

To have launchd start nginx at login:
    ln -sfv /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents
Then to load nginx now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
Or, if you don\'t want/need launchctl, you can just run:
    nginx
==> Summary
🍺  /usr/local/Cellar/nginx/1.4.4: 7 files, 876K, built in 14 seconds
[11:22:57]

Command Line Tool が必要と言われてるきがしてるけど、とりあえず進める

To have launchd start nginx at login: ln -sfv /usr/local/opt/nginx/*.plist ~/Library/LaunchAgents Then to load nginx now: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist Or, if you don't want/need launchctl, you can just run: nginx

と、あるので、

[11:25:36] → nginx
[11:26:02]

( ゚д゚) ? なにごともおきない

Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that nginx can run without sudo.

と言われているので、 http://localhost:8080/ にアクセス

f:id:otiai10:20140120114018p:plain

クララが立った

止めてみたいじゃない

[11:29:37] → nginx -h
nginx version: nginx/1.4.4
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:
  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /usr/local/Cellar/nginx/1.4.4/)
  -c filename   : set configuration file (default: /usr/local/etc/nginx/nginx.conf)
  -g directives : set global directives out of configuration file

[11:29:39]

ググった

[11:30:53] → nginx -s stop
[11:31:17]

f:id:otiai10:20140120114122p:plain

クララがしんだ

設定変えてみる

Docroot is: /usr/local/var/www

The default port has been set in /usr/local/etc/nginx/nginx.conf to 8080 so that nginx can run without sudo.

とのこと。

[11:43:28] → nginx

http://localhost:8080 で立ってることを確認

[11:43:36] → vi /usr/local/etc/nginx/nginx.conf
[11:44:32] → diff -u /usr/local/etc/nginx/nginx.conf.default /usr/local/etc/nginx/nginx.conf
--- /usr/local/etc/nginx/nginx.conf.default  2014-01-20 11:22:56.000000000 +0900
+++ /usr/local/etc/nginx/nginx.conf   2014-01-20 11:44:32.000000000 +0900
@@ -33,7 +33,7 @@
     #gzip  on;

     server {
-        listen       8080;
+        listen       9000;
         server_name  localhost;

         #charset koi8-r;
[11:44:34] → nginx -s reload

http://localhost:8080 が死んでることを確認して、 http://localhost:9000 にアクセスすると

f:id:otiai10:20140120114726p:plain

(・∀・)イイネ!!

DRY