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.
error_log logs/error.log;
events {
worker_connections 1024;
}
server {
listen 8080;
default_type text/html;
content_by_lua_block {
ngx.say("<p>hello, world</p>")
}
}
}
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 OpenResty into /usr/local/openresty
(this is the default), we make our nginx
executable of our 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
<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 Components page and find related stuff on the Nginx Wiki site.