How to install openresty in Ubuntu(2 way)

Posted by

Scalable Web Platform by Extending NGINX with Lua


From apt-get

Note: if nginx is already installed and running, try disabling and stopping it before installing openresty like below:

sudo systemctl disable nginx
sudo systemctl stop nginx

You can add our APT repository to your Ubuntu system so as to easily install our packages and receive updates in the future (via the apt-get update command). To add the repository, just run the following commands (only need to run once for each system):

# import our GPG key:
wget -qO - | sudo apt-key add -

# for installing the add-apt-repository command
# (you can remove this package and its dependencies later):
sudo apt-get -y install software-properties-common

# add the our official APT repository:
sudo add-apt-repository -y "deb $(lsb_release -sc) main"

# to update the APT index:
sudo apt-get update

Then you can install a package, say, openresty, like this:

sudo apt-get install openresty

This package also recommends the openresty-opm and openresty-restydoc packages so the latter two will also automatically get installed by default. If that is not what you want, you can disable the automatic installation of recommended packages like this:

sudo apt-get install --no-install-recommends openresty

From Source

Download code

apt-get install libpcre3-dev \
    libssl-dev perl make build-essential curl

tar -xvf openresty-VERSION.tar.gz
cd openresty-VERSION/
./configure -j2
make -j2
sudo make install

# better also add the following line to your ~/.bashrc or ~/.bash_profile file.
export PATH=/usr/local/openresty/bin:$PATH