First of all, please go to the Download page to get the source code tarball of , and see the Installation page for how to build and install it into your system.

HelloWorld

Prepare directory layout

We first create a separate directory for our experiments. You can use an arbitrary directory. Here for simplicity, we just use :

Note that we’ve also created the logs/ directory for logging files and conf/ for our config files.

  1. error_log logs/error.log;
  2. events {
  3. worker_connections 1024;
  4. }
  5. server {
  6. listen 8080;
  7. default_type text/html;
  8. content_by_lua_block {
  9. ngx.say("<p>hello, world</p>")
  10. }
  11. }
  12. }

If you’re familiar with configuration, it should look very familiar to you. OpenResty is just an enhanced version of by means of addon modules anyway. You can take advantage of all the exisitng goodies in the Nginx world.

Start the Nginx server

Assuming you have installed into /usr/local/openresty (this is the default), we make our nginx executable of our OpenResty installation available in our PATH environment:

Then we start the nginx server with our config file this way:

    We can use curl to access our new web service that says HelloWorld:

    If everything is okay, we should get the output

    1. <p>hello, world</p>

    You can surely point your favorite web browser to the location http://localhost:8080/.

    Test performance

    Where to go from here

    View the documentation of each component at the page and find Nginx related stuff on the .