Get the App
SLTechnology News&Howtos  ›  Servers  › 

Centos7 installs sample code for Nginx integration Lua

Shulou Source: shulou.com Published: 2022-06-02 02:13:49 09月26日 Update

Preface

The computer I use is Mac and the operating system is macOS Mojave. A virtual machine is installed on the computer.

Install the Centos7 operating system on the virtual machine, install Nginx and Luau class libraries on it, and record the whole process after the system installation is completed.

It is recommended to take a snapshot before installation and restore it if there is a problem.

Preparatory work

If the installed Linux is networked and the Linux port can be used externally, you can ignore the following two

1. Set to get ip automatically

(1) enter a command on Linux

[root@localhost ~] ip addr # View IP [root @ localhost ~] nmcli connection show

You can view the current Nic information

Mine is ens33.

(2) modify information

[root@localhost ~] vi / etc/sysconfig/network-scripts/ifcfg-ens33

Change the last line of ONBOOT=no to ONBOOT=yes

(3) restart network services

[root@localhost ~] # systemctl restart network

two。 Turn off the firewall

Systemctl stop firewalld.service # stop firewallsystemctl disable firewalld.service # disable firewall boot

3. When you are ready to install, you can find that there is no wget command. You can install it on the line first. If you are prompted below that there is no wget command, you can perform this step.

[root@localhost ~] # yum-y install wget

Installation

1. Installation depends on the environment

[root@localhost ~] # yum-y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

two。 Install LuaJIT

I created the LuaJIT folder under the / usr/local path

[root@localhost LuaJIT] # wget http://luajit.org/download/LuaJIT-2.0.2.tar.gz[root@localhost LuaJIT] # tar-xvf LuaJIT-2.0.2.tar.gz [root@localhost LuaJIT] # cd LuaJIT-2.0.2 [root@localhost LuaJIT-2.0.2] # make install

3. Install nginx

(1) download ngx_devel_kit, lua-nginx-module and nginx

I created the nginx folder under the / usr/local path

[root@localhost nginx] # wget https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz[root@localhost nginx] # wget https://github.com/openresty/lua-nginx-module/archive/v0.10.9rc7.tar.gz[root@localhost nginx] # wget http://nginx.org/download/nginx-1.12.1.tar.gz # Note the downloaded package does not have a file name But according to the version number, you can tell which file [root@localhost nginx] # tar-xvf v0.3.0.tar.gz [root@localhost nginx] # tar-xvf v0.10.9rc7.tar.gz [root@localhost nginx] # tar-xvf nginx-1.12.1.tar.gz

(2) compile Nginx

[root@localhost nginx] # cd nginx-1.12.1 [root@localhost nginx-1.12.1] #. / configure-prefix=/usr/local/nginx-add-module=../ngx_devel_kit-0.3.0-add-module=../lua-nginx-module-0.10.9rc7

(3) installation

[root@localhost nginx-1.12.1] # make [root@localhost nginx-1.12.1] # make install

(4) start nginx

Nginx may report an error at startup

. / nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: N

The file libluajit-5.1.so.2 cannot be found

Solution.

1. Find libluajit-5.1.so.2,libluajit-5.1.so.2.0.2 and copy these two files to the corresponding lib

64-bit is / usr/lib64

32-bit is / usr/lib

[root@localhost nginx-1.12.1] # find /-name libluajit-5.1.so.2

find

Files are installed under / usr/local/lib/libluajit-5.1.so.2 by default

[root@localhost nginx-1.12.1] # cp / usr/local/lib/libluajit-5.1.so.2 / usr/lib64/ [root@localhost nginx-1.12.1] # cp / usr/local/lib/libluajit-5.1.so.2.0.2 / usr/lib64

In the nginx installation directory, modify the nginx.conf file

Add the following code under the Server code block

Location / hello {default_type 'text/plain'; content_by_lua' ngx.say ("hello,lua")';}

Start nginx

[root@localhost nginx-1.12.1] #. / configure

Access the virtual corresponding address http://xxx.xxx.xxx/hello in the browser

Display as follows

So far, it's a success.

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Tags: File command is in system code operating system information folder computer path preparation success one line upload two content preface method name address Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Xiaomi macOS Docker vpn