Today I’d like to demonstrate how to install OpenResty on Ubuntu 20.04 via
We’ll use this fresh install of Ubuntu 20.04 in this video.
We can always goto the openresty.org web site to find the instructions. We can find all the commands for enabling the APT repository and installing the OpenResty Deb packages.
Back to our Ubuntu 20.04 system. If you already have anything listening on the local port 80, then you should disable it.
sudo lsof -i:80
Here we don’t have any.
First of all, make sure the system time is correct:
sudo ntpdate -v time.google.com
You may want to use a different NTP server near you here.
We should install some prerequisites needed by adding GPG public keys. These could be removed later.
sudo apt-get -y install --no-install-recommends wget gnupg ca-certificates
Let’s import our GPG key:
wget -O - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
Then add the our official APT repository.
echo "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main" > openresty.list
Note that this is for an
For Aarch64 or ARM64 systems, you should use this URL instead.
echo "deb http://openresty.org/package/arm64/ubuntu $(lsb_release -sc) main"
Now update the APT index:
sudo apt-get update
Note that we need
Now it’s time to install our main RPM package,
sudo apt-get -y install --no-install-recommends openresty
Check if the
openresty executable is available.
openresty executable is just a symbolic link.
file `which openresty`
And check its version.
We can start the default openresty server like this.
sudo systemctl start openresty
Check if the nginx processes are up and running.
ps aux|grep nginx
Test the default home page with the
Yay, it’s working.
Note, however, that the
resty command-line utility is not installed yet.
If you want it, then you can install the
openresty-resty RPM package from the same repository.
sudo apt-get -y install openresty-resty
Now it should be ready.
Similarly, if you want to use the
restydoc command-line utility, you should install the
sudo apt-get -y install openresty-restydoc
Now it’s available too.
restydoc -s content_by_lua_file
We can also install OPM for installing more Lua modules contributed by the OpenResty community.
sudo apt-get -y install openresty-opm
We can try installing the
lua-resty-http library authored by James Hurst.
sudo opm get pintsized/lua-resty-http
Try loading it with the
resty -e 'require "resty.http"'
There is also a debug build of OpenResty which includes debugging logs and all the internal assertions enabled.
sudo apt-get -y install openresty-debug
We can invoke this debug version of openresty like this.
openresty-debug executable is also a symbolic link.
file `which openresty-debug`
We should never use it in production since it is much slower than the release build.
Furthermore, there are also special builds for checking memory issues via Valgrind.
sudo apt list openresty-valgrind
Try these when you have memory issues to debug. We may cover these in future tutorials.
To upgrade OpenResty packages to their latest versions, just run these commands.
sudo apt-get update
To check all the available packages in our openresty repository.
apt list 'openresty*' | less
We’ve got a lot of binary packages here.
We can find detailed documentation for all these Deb packages on the web page https://openresty.org/en/deb-packages.html. We have indeed got a lot of packages for the user to choose from.
That’s all I’d like to cover today. Have fun!
If you like this tutorial, please subscribe to this blog site and our YouTube channel. Thank you!
This article and its associated video are both generated automatically from a simple screenplay file.
Yichun Zhang is the creator of the OpenResty® open source project. He is also the founder and CEO of the OpenResty Inc. company. He contributed a dozen open source Nginx 3rd-party modules, quite some Nginx and LuaJIT core patches, and designed the OpenResty XRay platform.
We provide the Chinese translation for this article on blog.openresty.com.cn. We also welcome interested readers to contribute translations in other natural languages as long as the full article is translated without any omissions. We thank them in advance.
We always welcome talented and enthusiastic engineers to join our team at OpenResty Inc.
to explore various open source software’s internals and build powerful analyzers and
visualizers for real world applications built atop the open source software. If you are
interested, please send your resume to
firstname.lastname@example.org . Thank you!