This post shows students and new users steps to find out the version of Nginx running on their system or install a specific Nginx version on Ubuntu Linux. For users who want to know what version of Nginx is running on their server, the steps below will show them how.
For those who also want to know how to install a specific version of Nginx on Ubuntu Linux, the steps below will also show them how to do that. In addition, the steps will also include options to find out what modules are loaded with Nginx on Ubuntu Linux.
For those who don’t know what Nginx is, here’s an overview:
Nginx is one of the most popular open-source web servers in the world. So chances are, many of the websites you visit today are most likely running the Nginx HTTP server. And if you’re thinking of running a website, you find yourself using an Nginx web server.
To get started with finding out what version of Nginx you’re running, or installing a specific Nginx version on Ubuntu Linux, continue below.
How to find out what version of Nginx you are running in Ubuntu Linux
Installing Nginx on Ubuntu Linux is easy. Run the apt-get install nginx commands to get it installed.
Run the commands below to check the Nginx version on the Ubuntu Linux command console.
nginx -v # OR nginx -V
Once you run the command above, it should output similar lines as below:
nginx version: nginx/1.18.0 (Ubuntu)
As you can see, version 1.18.0 is currently available in the Ubuntu repository. However, it doesn’t mean the latest Nginx version is available to be installed.
You may also be able to find more info on the Nginx version installed by running the commands below:
apt info nginx
When you run the commands above, it should list similar lines as below:
Package: nginx Version: 1.18.0-0ubuntu1.2 Priority: optional Section: web Origin: Ubuntu Maintainer: Ubuntu Developers <[email protected]> Original-Maintainer: Debian Nginx Maintainers <[email protected]> Bugs: https://bugs.launchpad.net/ubuntu/+filebug
If you have curl installed, you may also be able to tell what version of Nginx is running on Ubuntu Linux by using the commands below:
curl -I http://localhost/
When running the commands above, it should list something similar to the lines below:
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Tue, 28 Dec 2021 04:34:49 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 28 Dec 2021 04:32:13 GMT
Connection: keep-alive
ETag: "61ca934d-264"
Accept-Ranges: bytes
How to find out what Nginx modules are currently loaded in Ubuntu Linux
Now that you know how to find out what version of Nginx is installed on your system, the commands below show you how to list all the modules that are currently loaded with Nginx.
nginx -V
Once you run the commands above, it should output similar lines as below.
nginx version: nginx/1.18.0 (Ubuntu)
built with OpenSSL 1.1.1f 31 Mar 2020
TLS SNI support enabled
configure
arguments:
--with-cc-opt='-g
-O2
-fdebug-prefix-map=/build/nginx-KTLRnK/nginx-1.18.0=.
-fstack-protector-strong
-Wformat
-Werror=format-security
-fPIC
-Wdate-time
-D_FORTIFY_SOURCE=2'
--with-ld-opt='-Wl,-Bsymbolic-functions
-Wl,-z,relro
-Wl,-z,now
-fPIC'
--prefix=/usr/share/nginx
--conf-path=/etc/nginx/nginx.conf
--http-log-path=/var/log/nginx/access.log
--error-log-path=/var/log/nginx/error.log
--lock-path=/var/lock/nginx.lock
--pid-path=/run/nginx.pid
--modules-path=/usr/lib/nginx/modules
--http-client-body-temp-path=/var/lib/nginx/body
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi
--http-proxy-temp-path=/var/lib/nginx/proxy
--http-scgi-temp-path=/var/lib/nginx/scgi
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi
--with-debug
--with-compat
--with-pcre-jit
--with-http_ssl_module
--with-http_stub_status_module
--with-http_realip_module
--with-http_auth_request_module
--with-http_v2_module
--with-http_dav_module
--with-http_slice_module
--with-threads
--with-http_addition_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_image_filter_module=dynamic
--with-http_sub_module
--with-http_xslt_module=dynamic
--with-stream=dynamic
--with-stream_ssl_module
--with-mail=dynamic
--with-mail_ssl_module
Depending on your environment, the list above may be long or short.
How to install a specific version of Nginx on Ubuntu Linux
By default, the Ubuntu repository contains the latest stable version of Nginx. When you install Nginx from the Ubuntu repository, it will only install that specific version available.
You may have to add a third-party repository to your system if you need to install a specific version unavailable in Ubuntu Linux.
Run the commands below to add a repository to Ubuntu Linux that will allow you to install specific versions.
First, install the necessary commands below:
sudo apt update sudo apt install software-properties-common
Next, run the commands below to add the repository.
sudo add-apt-repository ppa:ondrej/nginx sudo apt-get update
After that, you can search for and install a specific version of Nginx.
apt-cache showpkg nginx
Install a specific version by running the command format below:
sudo apt-get install nginx-light=<complete version name>
Replace <complete version number> with the version number available for Ubuntu.
Example:
sudo apt install nginx-light=1.20.1-2+ubuntu20.04.1+deb.sury.org+1
Now the new version should reflect as shown below:
nginx version: nginx/1.20.1
That should do it!
Conclusion:
- Checking the Nginx version and installed modules can help ensure optimal server performance and compatibility.
- Installing a specific version of Nginx allows users to leverage features or fixes not present in the latest version.
- Utilizing
apt
commands simplifies the process of managing Nginx installations on Ubuntu Linux. - Always keep your server backed up and thoroughly test any changes in a development environment before applying them to production.
- For further customization, exploring third-party repositories can be invaluable in accessing additional versions and modules.
Leave a Reply to Janara Cancel reply