Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igorbarinov/12e2e650bc186db11b5e8cbb43c21242 to your computer and use it in GitHub Desktop.
Save igorbarinov/12e2e650bc186db11b5e8cbb43c21242 to your computer and use it in GitHub Desktop.
OpenResty + LuaRocks + Nchan + Redis (with password, graph and bloom modules)
#!/bin/sh
apt-get install -y libreadline-dev libncurses5-dev libpcre3-dev \
libssl-dev perl make build-essential git curl \
unzip
git clone https://github.com/RedisLabsModules/password.git /tmp/password
git clone https://github.com/RedisLabsModules/rebloom.git /tmp/rebloom
git clone https://github.com/RedisLabsModules/redis-graph.git /tmp/redis-graph
curl -L https://github.com/slact/nchan/archive/v1.1.10.tar.gz | tar xz -C /tmp
curl -L https://openresty.org/download/openresty-1.13.6.1.tar.gz | tar xz -C /tmp
curl -L http://download.redis.io/releases/redis-5.0.4.tar.gz | tar xz -C /tmp
cd /tmp/redis-5.0.4
make
sudo make install
adduser --system --no-create-home --group redis
mkdir -p /etc/redis
curl -L https://gist.githubusercontent.com/jmealo/e3cf626411980898a3581908b2b7d130/raw/0b6b2e05e3944b914ba4e76f0068dae0745fa6d8/redis.conf > /etc/redis/redis.conf
chown -R redis:redis /etc/redis
mkdir -p /var/run/redis
chown -R redis:redis /var/run/redis
mkdir -p /var/log/redis
chown -R redis:redis /var/log/redis
mkdir -p /var/lib/redis
chown -R redis:redis /var/lib/redis
mkdir -p /var/lib/redis/modules
chown -R redis:redis /var/lib/redis/modules
cd /tmp/password
make
cp password.so /var/lib/redis/modules
cd /tmp/rebloom
make
cp rebloom.so /var/lib/redis/modules
cd /tmp/redis-graph
make
cp src/redisgraph.so /var/lib/redis/modules
chown -R redis:redis /var/lib/redis/modules
curl -L https://gist.githubusercontent.com/jmealo/90a3263cafff87822543fec78e9e0849/raw/c7ec2cd60095a54ac8c50bb580e72532b2219f05/redis.service > /etc/systemd/system/redis-server.service
chmod 644 /etc/systemd/system/redis-server.service
service redis-server start
cd /tmp/openresty-1.13.6.1
./configure --add-module=/tmp/nchan-1.1.10 \
--with-stream \
--with-stream_ssl_module \
--with-debug
make
make install
curl -L http://luarocks.github.io/luarocks/releases/luarocks-2.4.4.tar.gz | tar xz -C /tmp
cd /tmp/luarocks-2.4.4
./configure --prefix=/usr/local/openresty/luajit \
--with-lua=/usr/local/openresty/luajit/ \
--lua-suffix=jit-2.1.0-beta3 \
--with-lua-include=/usr/local/openresty/luajit/include/luajit-2.1
make build
make install
luarocks install lua-struct
luarocks install lua-resty-http
git clone https://github.com/wojons/lua-resty-sse.git \
--branch master \
--single-branch /usr/local/openresty/lualib/resty/sse
curl -L https://gist.githubusercontent.com/jmealo/e3cf626411980898a3581908b2b7d130/raw/ea3147643821fbccbf06f36872b72a492a14536c/openresty.service > /etc/systemd/system/openresty.service
chmod 644 /etc/systemd/system/openresty.service
service openresty start
systemctl enable redis-server.service
systemctl enable openresty.service
# Enjoy luarocks as:
# sudo /usr/local/openresty/luajit/luarocks install lapis
# Luarocks was available as "/usr/local/openresty/luajit/luarocks~" for me, check that if it doesn't exist
[Unit]
Description=A dynamic web platform based on Nginx and LuaJIT.
After=network.target,redis-server.service
Wants=network.target,redis-server.service
[Service]
Type=forking
PIDFile=/usr/local/openresty/nginx/logs/nginx.pid
ExecStartPre=/usr/local/openresty/bin/openresty -t -q -g 'daemon on; master_process on;'
ExecStart=/usr/local/openresty/bin/openresty -g 'daemon on; master_process on;'
ExecReload=/usr/local/openresty/bin/openresty -g 'daemon on; master_process on;' -s reload
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /usr/local/openresty/nginx/logs/nginx.pid
TimeoutStopSec=5
KillMode=mixed
[Install]
WantedBy=multi-user.target
[Unit]
Description=Redis In-Memory Data Store
After=network.target
[Service]
Type=forking
PIDFile=/var/run/redis/redis.pid
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=0700
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always
[Install]
WantedBy=multi-user.target
daemonize yes
pidfile /var/run/redis/redis.pid
# Uncomment below to disable listening on TCP socket
# port 0
bind 127.0.0.1
unixsocket /var/run/redis/redis.sock
unixsocketperm 755
loglevel notice
logfile /var/log/redis/redis.log
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump-production.rdb
dir /var/lib/redis
loadmodule /var/lib/redis/modules/password.so
loadmodule /var/lib/redis/modules/redisgraph.so
loadmodule /var/lib/redis/modules/rebloom.so
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment