Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install Nginx Integration Lua for Centos7

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "Centos7 how to install Nginx integration Lua", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Centos7 how to install Nginx integration Lua" bar!

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

Thank you for reading, the above is "Centos7 how to install Nginx integration Lua" content, after the study of this article, I believe you on how to install Centos7 Nginx integration Lua this problem has a deeper understanding, the specific use of the need for you to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report