环境

1
2
~# cat /etc/issue
Ubuntu 14.04.1 LTS

安装OpenResty

1
2
3
4
5
6
7
8
9
10
~# apt-get install libreadline-dev libpcre3-dev libssl-dev perl
~# mkdir src
~# cd src/
~/src# wget http://openresty.org/download/ngx_openresty-1.7.10.2.tar.gz
~/src# tar axvf ngx_openresty-1.7.10.2.tar.gz
~/src# cd ngx_openresty-1.7.10.2/
#by default --prefix=/usr/local/openresty
/src/ngx_openresty-1.7.10.2# ./configure --with-luajit \
--without-http_redis2_module \
--with-http_iconv_module

为luajit安装luarocks

1
2
3
4
5
6
7
8
9
10
11
12
~/src# wget wget http://luarocks.org/releases/luarocks-2.2.2.tar.gz
~/src# tar zxvf luarocks-2.2.2.tar.gz
~/src# cd luarocks-2.2.2/
~/src# ln -s /usr/local/openresty/luajit/bin/luajit-2.1.0-alpha /usr/local/openresty/luajit/bin/luajit
~/src# find / -name lua.h
~/src/luarocks-2.2.2# ./configure --with-lua="/usr/local/openresty/luajit" --lua-suffix="jit" --with-lua-include="/usr/local/openresty/luajit/include/luajit-2.1"
...
Installation prefix: /usr/local
LuaRocks configuration directory: /usr/local/etc/luarocks
Using Lua from: /usr/local/openresty/luajit
...
~/src/luarocks-2.2.2# make build && make install

Lapis 安装

1
~# luarocks install lapis

nginx 启动脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#! /bin/sh
# chkconfig: 2345 55 25
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
# run 'update-rc.d -f nginx defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add nginx'

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx"
NAME=nginx
DAEMON=/usr/local/openresty/nginx/sbin/$NAME
CONFIGFILE=/usr/local/openresty/nginx/conf/$NAME.conf
PIDFILE=/usr/local/openresty/nginx/logs/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

set -e
[ -x "$DAEMON" ] || exit 0

do_start() {
$DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}

do_stop() {
kill -INT `cat $PIDFILE` || echo -n "nginx not running"
}

do_reload() {
kill -HUP `cat $PIDFILE` || echo -n "nginx can't reload"
}

case "$1" in
start)
echo -n "Starting $DESC: $NAME"
do_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
do_stop
echo "."
;;
reload|graceful)
echo -n "Reloading $DESC configuration..."
do_reload
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
do_stop
do_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac

exit 0

参考

资料