Created
April 23, 2016 11:19
-
-
Save opn/280754d59d258305731e5fdcc1d2a15d to your computer and use it in GitHub Desktop.
Nginx with LUA installation on OSX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ brew update | |
Updated Homebrew from 2921795 to c20622a. | |
Updated 1 tap (homebrew/core). | |
==> New Formulae | |
parquet-tools | |
==> Updated Formulae | |
buku gst-plugins-good kubernetes-cli | |
gst-editing-services gst-plugins-ugly solr | |
gst-libav gst-python tippecanoe | |
gst-plugins-bad gst-validate | |
gst-plugins-base gstreamer | |
$ brew install pcre openssl | |
Warning: pcre-8.38 already installed | |
Warning: openssl-1.0.2g already installed | |
$ pwd | |
/Users/BabyBlue/WebServer | |
$ ls | |
WebServer node_modules www | |
david-2:WebServer BabyBlue$ cd .. | |
david-2:~ BabyBlue$ ls | |
Applications Downloads Library Pictures app.log mydockerbuild | |
Desktop Dropbox Movies Public dapps public_html | |
Documents Google Drive Music WebServer go station | |
$ mkdir work | |
$ cd work | |
$ mkdir logs/ conf/ | |
$ nano conf/nginx,conf | |
$ nano conf/nginx.conf | |
$ ls -la /usr/local/openresty | |
total 0 | |
drwxr-xr-x 6 BabyBlue admin 204 23 Apr 11:30 . | |
drwxr-xr-x 26 BabyBlue admin 884 23 Apr 11:30 .. | |
drwxr-xr-x 3 BabyBlue admin 102 23 Apr 11:30 bin | |
drwxr-xr-x 6 BabyBlue admin 204 23 Apr 11:30 luajit | |
drwxr-xr-x 7 BabyBlue admin 238 23 Apr 11:30 lualib | |
drwxr-xr-x 6 BabyBlue admin 204 23 Apr 11:30 nginx | |
$ PATH = /usr/local/openresty/nginx/sbin:$PATH | |
-bash: PATH: command not found | |
$ nano ~/.bash_profile | |
$ ls $HOME/.bash_profile | |
ls: /Users/BabyBlue/.bash_profile: No such file or directory | |
$ echo $PATH | |
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/usr/local/MacGPG2/bin:/bin:/Users/BabyBlue/go/bin | |
$ nano ~/.bash_profile | |
$ export PATH=$PATH:/usr/local/openresty/nginx/sbin | |
$ nano ~/.bash_profile | |
$ nginx -p `pwd`/ -c conf/nginx.conf | |
nginx: [alert] could not open error log file: open() "/usr/local/var/log/nginx/error.log" failed (13: Permission denied) | |
2016/04/23 11:45:34 [emerg] 628#0: unknown directive "content_by_lua" in /Users/BabyBlue/work/conf/nginx.conf:13 | |
$ pwd | |
/Users/BabyBlue/work | |
$ ls | |
conf logs | |
$ sudo nginx -p `pwd`/ -c conf/nginx.conf | |
Password: | |
nginx: [emerg] unknown directive "content_by_lua" in /Users/BabyBlue/work/conf/nginx.conf:13 | |
$ brew install luajit | |
==> Downloading https://homebrew.bintray.com/bottles/luajit-2.0.4_1.el_capitan.bottle.tar.gz | |
######################################################################## 100.0% | |
==> Pouring luajit-2.0.4_1.el_capitan.bottle.tar.gz | |
🍺 /usr/local/Cellar/luajit/2.0.4_1: 30 files, 1.9M | |
$ sudo nginx -p `pwd`/ -c conf/nginx.conf | |
nginx: [emerg] unknown directive "content_by_lua" in /Users/BabyBlue/work/conf/nginx.conf:13 | |
$ brew tap homebrew/nginx | |
==> Tapping homebrew/nginx | |
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-nginx'... | |
remote: Counting objects: 66, done. | |
remote: Compressing objects: 100% (66/66), done. | |
remote: Total 66 (delta 0), reused 48 (delta 0), pack-reused 0 | |
Unpacking objects: 100% (66/66), done. | |
Checking connectivity... done. | |
Tapped 59 formulae (150 files, 117.5K) | |
$ brew tap homebrew/nginx | |
$ brew options nginx-full | |
--with-accept-language-module | |
Compile with support for Accept Language module | |
--with-accesskey-module | |
Compile with support for HTTP Access Key module | |
--with-addition | |
Compile with support for HTTP Addition module | |
--with-ajp-module | |
Compile with support for AJP-protocol | |
--with-anti-ddos-module | |
Compile with support for Anti-DDoS module | |
--with-array-var-module | |
Compile with support for Array Var module | |
--with-auth-digest-module | |
Compile with support for Auth Digest module | |
--with-auth-ldap-module | |
Compile with support for Auth LDAP module | |
--with-auth-pam-module | |
Compile with support for Auth PAM module | |
--with-auth-req | |
Compile with support for HTTP Auth Request module | |
--with-auto-keepalive-module | |
Compile with support for Auto Disable KeepAlive module | |
--with-autols-module | |
Compile with support for Flexible Auto Index module | |
--with-cache-purge-module | |
Compile with support for Cache Purge module | |
--with-captcha-module | |
Compile with support for Captcha module | |
... | |
--with-lua-module | |
Compile with support for LUA module | |
... | |
--with-xslt | |
Compile with support for XSLT module | |
--with-xsltproc-module | |
Compile with support for XSLT transformations | |
--without-openssl | |
Build without openssl support | |
--devel | |
Install development version 1.9.15 | |
--HEAD | |
Install HEAD version | |
$ brew unlink nginx | |
Unlinking /usr/local/Cellar/nginx/1.8.1... 2 symlinks removed | |
$ brew link nginx-full | |
Error: No such keg: /usr/local/Cellar/nginx-full | |
$ brew tap homebrew/nginx | |
$ brew install nginx-full --with-lua-module | |
==> Installing nginx-full from homebrew/nginx | |
==> Installing dependencies for homebrew/nginx/nginx-full: ngx-devel-kit, lua-nginx-module | |
==> Installing homebrew/nginx/nginx-full dependency: ngx-devel-kit | |
==> Downloading https://github.com/simpl/ngx_devel_kit/archive/v0.3.0rc1.tar.gz | |
==> Downloading from https://codeload.github.com/simpl/ngx_devel_kit/tar.gz/v0.3.0rc1 | |
######################################################################## 100.0% | |
🍺 /usr/local/Cellar/ngx-devel-kit/1: 89 files, 553.3K, built in 3 seconds | |
==> Installing homebrew/nginx/nginx-full dependency: lua-nginx-module | |
==> Downloading https://github.com/openresty/lua-nginx-module/archive/v0.10.2.tar.gz | |
==> Downloading from https://codeload.github.com/openresty/lua-nginx-module/tar.gz/v0.10.2 | |
######################################################################## 100.0% | |
==> Downloading https://github.com/openresty/lua-nginx-module/compare/v0.10.2...d44f8e0.diff | |
######################################################################## 100.0% | |
==> Patching | |
==> Applying v0.10.2...d44f8e0.diff | |
patching file src/api/ngx_http_lua_api.h | |
patching file src/ngx_http_lua_initworkerby.c | |
patching file src/ngx_http_lua_misc.c | |
patching file src/ngx_http_lua_req_body.c | |
patching file src/ngx_http_lua_variable.c | |
patching file t/015-status.t | |
🍺 /usr/local/Cellar/lua-nginx-module/0.10.2: 325 files, 3.9M, built in 5 seconds | |
==> Installing homebrew/nginx/nginx-full | |
==> Downloading http://nginx.org/download/nginx-1.8.1.tar.gz | |
######################################################################## 100.0% | |
==> ./configure --prefix=/usr/local/Cellar/nginx-full/1.8.1 --with-http_ssl_module --with-pcre --with-ipv6 --sbin-path=/usr/local/Cellar/ngi | |
==> 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. | |
nginx will load all files in /usr/local/etc/nginx/servers/. | |
- Tips - | |
Run port 80: | |
$ sudo chown root:wheel /usr/local/Cellar/nginx-full/1.8.1/bin/nginx | |
$ sudo chmod u+s /usr/local/Cellar/nginx-full/1.8.1/bin/nginx | |
Reload config: | |
$ nginx -s reload | |
Reopen Logfile: | |
$ nginx -s reopen | |
Stop process: | |
$ nginx -s stop | |
Waiting on exit process | |
$ nginx -s quit | |
To have launchd start homebrew/nginx/nginx-full now and restart at login: | |
brew services start homebrew/nginx/nginx-full | |
Or, if you don't want/need a background service you can just run: | |
nginx | |
==> Summary | |
🍺 /usr/local/Cellar/nginx-full/1.8.1: 7 files, 1.2M, built in 42 seconds | |
$ brew unlink nginx | |
Unlinking /usr/local/Cellar/nginx/1.8.1... 0 symlinks removed | |
$ brew link nginx-full | |
Warning: Already linked: /usr/local/Cellar/nginx-full/1.8.1 | |
To relink: brew unlink nginx-full && brew link nginx-full | |
$ nginx -p `pwd`/ -c conf/nginx.conf | |
nginx: [alert] could not open error log file: open() "/usr/local/var/log/nginx/error.log" failed (13: Permission denied) | |
2016/04/23 11:55:27 [emerg] 4608#0: open() "/usr/local/var/log/nginx/access.log" failed (13: Permission denied) | |
$ sudo nginx -p `pwd`/ -c conf/nginx.conf | |
Password: | |
david-2:work BabyBlue$ curl http://localhost:8082/ | |
<p>hello, world</p> | |
$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment