This is the 27th day of my participation in the August More Text Challenge

Based on Nginx’s modular design, many third-party modules have been derived to extend Nginx’s capabilities. One interesting and far-reaching module is the Lua-nginx-Module. It builds a Lua parser into Nginx so that you can program in Lua, greatly enhancing Nginx’s capabilities.

Lua is a lightweight, compact scripting language written in standard C with source code and designed to be embedded into applications to provide flexible extension and customization capabilities

OpenResty(openresty.org/cn/) is a high-performance Web platform based on Nginx and Lua, which integrates a large number of sophisticated Lua libraries, third-party modules and most dependencies to build dynamic Web applications that can handle extremely high concurrency and scalability. Web services and dynamic gateways.

The following uses Ubuntu 1604 (LTS) as an example to describe how to install and use OpenResty

  1. To install the dependent libraries, run the following command:
sudo apt install -y libpcre3-dev libssl-dev perl make build-essential curl
Copy the code
  1. From the official (openresty.org/cn/download OpenResty…
Wget https://openresty.org/download/openresty-1.13.6.1.tar.gztar - XVF openresty - 1.13.6.1. Tar. Gz CD openresty - 1.13.6.1 ./configure -j2 make -j2 sudo make installCopy the code

By default, the program is installed in the “/usr/local/openresty” directory. You can also use “./configuure –help” to see more configuration options

  1. After the installation is successful, create a new Nginx configuration file before starting OpenRestyconfgi/nginx.conf, the code is as follows:
worker_processes 1; error_log logs/error.log; events { worker_connections 1024 } http { server { listen 9000; location / { default_type text/html; content_by_lua ' ngx.say("<p>Hello, World! <p>") '; }}}Copy the code

Tips: For the introduction and use of Lua, please refer to the official Lua documentation: www.lua.org/docs.html

  1. To start the OpenResty service, run the following command:
/usr/local/openresty/nginx/sbin/nginx -p `pwd`/ -c conf/nginx.conf
Copy the code

If no output is displayed, the startup is successful. -p specifies the project directory and -c specifies the configuration file

  1. Using cURL to access this service:
curl http://localhost:8080/
Copy the code
  1. The following output is displayed:
<p>Hello, World! <p>Copy the code

In short, OpenResty is an extension based on Nginx, and the development language is no longer the C implementation of Nginx, but the simpler, easy-to-use Lua language

The last

Public number: small he growth, the Buddha department more text, are their own once stepped on the pit or is learned things

Interested little partners welcome to pay attention to me oh, I was: he Small Life. Everybody progress duck together