Step 1: install luarocks
root@tutorialspots1:~# apt-get install luarocks Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: autoconf automake autotools-dev file libltdl-dev liblua5.1-0 liblua5.1-0-dev libmagic-mgc libmagic1 libncurses-dev libreadline-dev libtool libtool-bin lua-any lua-sec lua-socket lua5.1 m4 unzip zip Suggested packages: autoconf-archive gnu-standards autoconf-doc gettext libtool-doc ncurses-doc readline-doc gfortran | fortran95-compiler gcj-jdk m4-doc The following NEW packages will be installed: autoconf automake autotools-dev file libltdl-dev liblua5.1-0 liblua5.1-0-dev libmagic-mgc libmagic1 libncurses-dev libreadline-dev libtool libtool-bin lua-any lua-sec lua-socket lua5.1 luarocks m4 unzip zip 0 upgraded, 21 newly installed, 0 to remove and 34 not upgraded. Need to get 3,140 kB of archives. After this operation, 20.3 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 https://mirror.hetzner.com/ubuntu/packages focal/main amd64 libmagic-mgc amd64 1:5.38-4 [218 kB] Get:2 https://mirror.hetzner.com/ubuntu/packages focal/main amd64 libmagic1 amd64 1:5.38-4 [75.9 kB] Get:3 https://mirror.hetzner.com/ubuntu/packages focal/main amd64 file amd64 1:5.38-4 [23.3 kB] Get:4 https://mirror.hetzner.com/ubuntu/packages focal/main amd64 m4 amd64 1.4.18-4 [199 kB] Get:5 https://mirror.hetzner.com/ubuntu/packages focal/main amd64 autoconf all 2.69-11.1 [321 kB] Get:6 https://mirror.hetzner.com/ubuntu/packages focal/main amd64 autotools-dev all 20180224.1 [39.6 kB] Get:7 https://mirror.hetzner.com/ubuntu/packages focal/main amd64 automake all 1:1.16.1-4ubuntu6 [522 kB] Get:8 https://mirror.hetzner.com/ubuntu/packages focal/main amd64 libltdl-dev amd64 2.4.6-14 [162 kB] Get:9 https://mirror.hetzner.com/ubuntu/packages focal/universe amd64 liblua5.1-0 amd64 5.1.5-8.1build4 [99.9 kB] Get:10 https://mirror.hetzner.com/ubuntu/packages focal/main amd64 libncurses-dev amd64 6.2-0ubuntu2 [339 kB] Get:11 https://mirror.hetzner.com/ubuntu/packages focal/main amd64 libreadline-dev amd64 8.0-4 [141 kB] Get:12 https://mirror.hetzner.com/ubuntu/packages focal/universe amd64 liblua5.1-0-dev amd64 5.1.5-8.1build4 [122 kB] Get:13 https://mirror.hetzner.com/ubuntu/packages focal/main amd64 libtool all 2.4.6-14 [161 kB] Get:14 https://mirror.hetzner.com/ubuntu/packages focal/main amd64 libtool-bin amd64 2.4.6-14 [80.1 kB] Get:15 https://mirror.hetzner.com/ubuntu/packages focal/universe amd64 lua5.1 amd64 5.1.5-8.1build4 [94.6 kB] Get:16 https://mirror.hetzner.com/ubuntu/packages focal/universe amd64 lua-any all 25 [4,960 B] Get:17 https://mirror.hetzner.com/ubuntu/packages focal/universe amd64 lua-socket amd64 3.0~rc1+git+ac3201d-4 [70.5 kB] Get:18 https://mirror.hetzner.com/ubuntu/packages focal/universe amd64 lua-sec amd64 0.9-3 [32.3 kB] Get:19 https://mirror.hetzner.com/ubuntu/packages focal/main amd64 zip amd64 3.0-11build1 [167 kB] Get:20 https://mirror.hetzner.com/ubuntu/packages focal/main amd64 unzip amd64 6.0-25ubuntu1 [169 kB] Get:21 https://mirror.hetzner.com/ubuntu/packages focal/universe amd64 luarocks all 2.4.2+dfsg-1 [97.6 kB] Fetched 3,140 kB in 5s (631 kB/s) Selecting previously unselected package libmagic-mgc. (Reading database ... 45192 files and directories currently installed.) Preparing to unpack .../00-libmagic-mgc_1%3a5.38-4_amd64.deb ... Unpacking libmagic-mgc (1:5.38-4) ... Selecting previously unselected package libmagic1:amd64. Preparing to unpack .../01-libmagic1_1%3a5.38-4_amd64.deb ... Unpacking libmagic1:amd64 (1:5.38-4) ... Selecting previously unselected package file. Preparing to unpack .../02-file_1%3a5.38-4_amd64.deb ... Unpacking file (1:5.38-4) ... Selecting previously unselected package m4. Preparing to unpack .../03-m4_1.4.18-4_amd64.deb ... Unpacking m4 (1.4.18-4) ... Selecting previously unselected package autoconf. Preparing to unpack .../04-autoconf_2.69-11.1_all.deb ... Unpacking autoconf (2.69-11.1) ... Selecting previously unselected package autotools-dev. Preparing to unpack .../05-autotools-dev_20180224.1_all.deb ... Unpacking autotools-dev (20180224.1) ... Selecting previously unselected package automake. Preparing to unpack .../06-automake_1%3a1.16.1-4ubuntu6_all.deb ... Unpacking automake (1:1.16.1-4ubuntu6) ... Selecting previously unselected package libltdl-dev:amd64. Preparing to unpack .../07-libltdl-dev_2.4.6-14_amd64.deb ... Unpacking libltdl-dev:amd64 (2.4.6-14) ... Selecting previously unselected package liblua5.1-0:amd64. Preparing to unpack .../08-liblua5.1-0_5.1.5-8.1build4_amd64.deb ... Unpacking liblua5.1-0:amd64 (5.1.5-8.1build4) ... Selecting previously unselected package libncurses-dev:amd64. Preparing to unpack .../09-libncurses-dev_6.2-0ubuntu2_amd64.deb ... Unpacking libncurses-dev:amd64 (6.2-0ubuntu2) ... Selecting previously unselected package libreadline-dev:amd64. Preparing to unpack .../10-libreadline-dev_8.0-4_amd64.deb ... Unpacking libreadline-dev:amd64 (8.0-4) ... Selecting previously unselected package liblua5.1-0-dev:amd64. Preparing to unpack .../11-liblua5.1-0-dev_5.1.5-8.1build4_amd64.deb ... Unpacking liblua5.1-0-dev:amd64 (5.1.5-8.1build4) ... Selecting previously unselected package libtool. Preparing to unpack .../12-libtool_2.4.6-14_all.deb ... Unpacking libtool (2.4.6-14) ... Selecting previously unselected package libtool-bin. Preparing to unpack .../13-libtool-bin_2.4.6-14_amd64.deb ... Unpacking libtool-bin (2.4.6-14) ... Selecting previously unselected package lua5.1. Preparing to unpack .../14-lua5.1_5.1.5-8.1build4_amd64.deb ... Unpacking lua5.1 (5.1.5-8.1build4) ... Selecting previously unselected package lua-any. Preparing to unpack .../15-lua-any_25_all.deb ... Unpacking lua-any (25) ... Selecting previously unselected package lua-socket:amd64. Preparing to unpack .../16-lua-socket_3.0~rc1+git+ac3201d-4_amd64.deb ... Unpacking lua-socket:amd64 (3.0~rc1+git+ac3201d-4) ... Selecting previously unselected package lua-sec:amd64. Preparing to unpack .../17-lua-sec_0.9-3_amd64.deb ... Unpacking lua-sec:amd64 (0.9-3) ... Selecting previously unselected package zip. Preparing to unpack .../18-zip_3.0-11build1_amd64.deb ... Unpacking zip (3.0-11build1) ... Selecting previously unselected package unzip. Preparing to unpack .../19-unzip_6.0-25ubuntu1_amd64.deb ... Unpacking unzip (6.0-25ubuntu1) ... Selecting previously unselected package luarocks. Preparing to unpack .../20-luarocks_2.4.2+dfsg-1_all.deb ... Unpacking luarocks (2.4.2+dfsg-1) ... Setting up libncurses-dev:amd64 (6.2-0ubuntu2) ... Setting up libmagic-mgc (1:5.38-4) ... Setting up unzip (6.0-25ubuntu1) ... Setting up libmagic1:amd64 (1:5.38-4) ... Setting up m4 (1.4.18-4) ... Setting up lua-socket:amd64 (3.0~rc1+git+ac3201d-4) ... Setting up file (1:5.38-4) ... Setting up libreadline-dev:amd64 (8.0-4) ... Setting up lua5.1 (5.1.5-8.1build4) ... update-alternatives: using /usr/bin/lua5.1 to provide /usr/bin/lua (lua-interpreter) in auto mode update-alternatives: using /usr/bin/luac5.1 to provide /usr/bin/luac (lua-compiler) in auto mode Setting up zip (3.0-11build1) ... Setting up autotools-dev (20180224.1) ... Setting up autoconf (2.69-11.1) ... Setting up liblua5.1-0:amd64 (5.1.5-8.1build4) ... Setting up automake (1:1.16.1-4ubuntu6) ... update-alternatives: using /usr/bin/automake-1.16 to provide /usr/bin/automake (automake) in auto mode Setting up lua-sec:amd64 (0.9-3) ... Setting up liblua5.1-0-dev:amd64 (5.1.5-8.1build4) ... Setting up libtool (2.4.6-14) ... Setting up lua-any (25) ... Setting up libltdl-dev:amd64 (2.4.6-14) ... Setting up libtool-bin (2.4.6-14) ... Setting up luarocks (2.4.2+dfsg-1) ... Making manifest for /usr/local/lib/luarocks/rocks Warning: This looks like a local rocks tree, but you did not pass --local-tree. Generating index.html for /usr/local/lib/luarocks/rocks Processing triggers for man-db (2.9.1-1) ... Processing triggers for install-info (6.7.0.dfsg.2-5) ... Processing triggers for mime-support (3.64ubuntu1) ... Processing triggers for libc-bin (2.31-0ubuntu9.7) ...
Step 2: install libbson and libmongoc
root@tutorialspots1:~# apt-get install -y libbson-dev Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libbson-1.0-0 The following NEW packages will be installed: libbson-1.0-0 libbson-dev 0 upgraded, 2 newly installed, 0 to remove and 34 not upgraded. Need to get 187 kB of archives. After this operation, 835 kB of additional disk space will be used. Get:1 https://mirror.hetzner.com/ubuntu/packages focal/universe amd64 libbson-1.0-0 amd64 1.16.1-1build2 [70.2 kB] Get:2 https://mirror.hetzner.com/ubuntu/packages focal/universe amd64 libbson-dev amd64 1.16.1-1build2 [117 kB] Fetched 187 kB in 0s (1,302 kB/s) Selecting previously unselected package libbson-1.0-0. (Reading database ... 46112 files and directories currently installed.) Preparing to unpack .../libbson-1.0-0_1.16.1-1build2_amd64.deb ... Unpacking libbson-1.0-0 (1.16.1-1build2) ... Selecting previously unselected package libbson-dev. Preparing to unpack .../libbson-dev_1.16.1-1build2_amd64.deb ... Unpacking libbson-dev (1.16.1-1build2) ... Setting up libbson-1.0-0 (1.16.1-1build2) ... Setting up libbson-dev (1.16.1-1build2) ... Processing triggers for libc-bin (2.31-0ubuntu9.7) ...
root@tutorialspots1:~# apt-get install -y libmongoc-dev Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libmongoc-1.0-0 libsasl2-dev libsnappy-dev libsnappy1v5 The following NEW packages will be installed: libmongoc-1.0-0 libmongoc-dev libsasl2-dev libsnappy-dev libsnappy1v5 0 upgraded, 5 newly installed, 0 to remove and 34 not upgraded. Need to get 534 kB of archives. After this operation, 2,021 kB of additional disk space will be used. Get:1 https://mirror.hetzner.com/ubuntu/packages focal/main amd64 libsnappy1v5 amd64 1.1.8-1build1 [16.7 kB] Get:2 https://mirror.hetzner.com/ubuntu/packages focal/universe amd64 libmongoc-1.0-0 amd64 1.16.1-1build2 [234 kB] Get:3 https://mirror.hetzner.com/ubuntu/packages focal/main amd64 libsnappy-dev amd64 1.1.8-1build1 [29.0 kB] Get:4 https://mirror.hetzner.com/ubuntu/packages focal-updates/main amd64 libsasl2-dev amd64 2.1.27+dfsg-2ubuntu0.1 [226 kB] Get:5 https://mirror.hetzner.com/ubuntu/packages focal/universe amd64 libmongoc-dev amd64 1.16.1-1build2 [28.9 kB] Fetched 534 kB in 0s (2,966 kB/s) Selecting previously unselected package libsnappy1v5:amd64. (Reading database ... 46168 files and directories currently installed.) Preparing to unpack .../libsnappy1v5_1.1.8-1build1_amd64.deb ... Unpacking libsnappy1v5:amd64 (1.1.8-1build1) ... Selecting previously unselected package libmongoc-1.0-0. Preparing to unpack .../libmongoc-1.0-0_1.16.1-1build2_amd64.deb ... Unpacking libmongoc-1.0-0 (1.16.1-1build2) ... Selecting previously unselected package libsnappy-dev:amd64. Preparing to unpack .../libsnappy-dev_1.1.8-1build1_amd64.deb ... Unpacking libsnappy-dev:amd64 (1.1.8-1build1) ... Selecting previously unselected package libsasl2-dev. Preparing to unpack .../libsasl2-dev_2.1.27+dfsg-2ubuntu0.1_amd64.deb ... Unpacking libsasl2-dev (2.1.27+dfsg-2ubuntu0.1) ... Selecting previously unselected package libmongoc-dev. Preparing to unpack .../libmongoc-dev_1.16.1-1build2_amd64.deb ... Unpacking libmongoc-dev (1.16.1-1build2) ... Setting up libsnappy1v5:amd64 (1.1.8-1build1) ... Setting up libsasl2-dev (2.1.27+dfsg-2ubuntu0.1) ... Setting up libmongoc-1.0-0 (1.16.1-1build2) ... Setting up libsnappy-dev:amd64 (1.1.8-1build1) ... Setting up libmongoc-dev (1.16.1-1build2) ... Processing triggers for man-db (2.9.1-1) ... Processing triggers for libc-bin (2.31-0ubuntu9.7) ...
Step 3: install Lua Mongo
root@tutorialspots1:~# luarocks install lua-mongo Installing https://luarocks.org/lua-mongo-1.2.3-1.src.rock gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/bson.c -o src/bson.o -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/bsontype.c -o src/bsontype.o -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/bulkoperation.c -o src/bulkoperation.o -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/client.c -o src/client.o -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/collection.c -o src/collection.o -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/cursor.c -o src/cursor.o -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/database.c -o src/database.o -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/flags.c -o src/flags.o -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/gridfs.c -o src/gridfs.o -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/gridfsfile.c -o src/gridfsfile.o -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/gridfsfilelist.c -o src/gridfsfilelist.o -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/main.c -o src/main.o -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/objectid.c -o src/objectid.o -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/readprefs.c -o src/readprefs.o -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/util.c -o src/util.o -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 gcc -shared -o mongo.so -L/usr/local/lib src/bson.o src/bsontype.o src/bulkoperation.o src/client.o src/collection.o src/cursor.o src/database.o src/flags.o src/gridfs.o src/gridfsfile.o src/gridfsfilelist.o src/main.o src/objectid.o src/readprefs.o src/util.o -L/usr/lib -L/usr/lib -Wl,-rpath,/usr/lib: -Wl,-rpath,/usr/lib: -lmongoc-1.0 -lbson-1.0 lua-mongo 1.2.3-1 is now installed in /usr/local (license: MIT)
Done! now we have file /usr/local/lib/lua/5.1/mongo.so
Note: to use with nginx you must use this line in config file:
lua_package_cpath "/usr/local/lib/lua/?.so;;";