• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to Install and Configure Nginx on Debian 11.4

  • 00:34 lsb_release -a
  • 00:41 apt install nginx
  • 01:12 systemctl start nginx
  • 01:18 systemctl enable nginx
  • 01:35 mkdir /var/www/test1.com
  • 01:51 vi /var/www/test1.com/index.html
  • 02:20 chown -R www-data. /var/www/test1.com/
  • 02:42 chown -R www-data. /var/www/test1.com/
  • 03:11 ln -s /etc/nginx/sites-available/test1.com /etc/nginx/sites-enabled/test1.com
  • 03:54 vim /etc/hosts
  • 04:52 systemctl restart nginx
{{postValue.id}}

To Install And Configure Nginx On Debian 11.4

Introduction:

Nginx is a free and open-source application for Linux that is used to direct web traffic to a specific server as a reverse proxy server. It is possible to use Nginx as a web server independently.

Installation Procedure:

Step 1: Check the OS version by using the below command

root@debian:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye

Step 2: Install the Nginx by using the below command

root@debian:~# apt install nginx
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  dbconfig-common dbconfig-mysql default-mysql-client galera-4 icc-profiles-free libaio1 libcgi-fast-perl libcgi-pm-perl
  libconfig-inifiles-perl libdbd-mariadb-perl libdbi-perl libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-template-perl
  libjs-bootstrap4 libjs-codemirror libjs-jquery libjs-jquery-mousewheel libjs-jquery-timepicker libjs-jquery-ui
  libjs-openlayers libjs-popper.js libjs-sizzle libjs-sphinxdoc libjs-underscore libmariadb3 libonig5 libterm-readkey-perl
  libzip4 mariadb-client-10.5 mariadb-client-core-10.5 mariadb-common mariadb-server-10.5 mariadb-server-core-10.5
  mysql-common node-jquery rsync socat
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
  geoip-database libgeoip1 libnginx-mod-http-geoip libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter
  libnginx-mod-mail libnginx-mod-stream libnginx-mod-stream-geoip nginx-common nginx-core
Suggested packages:
  geoip-bin fcgiwrap nginx-doc
The following NEW packages will be installed:
  geoip-database libgeoip1 libnginx-mod-http-geoip libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter
  libnginx-mod-mail libnginx-mod-stream libnginx-mod-stream-geoip nginx nginx-common nginx-core
0 upgraded, 11 newly installed, 0 to remove and 208 not upgraded.
Need to get 4,541 kB of archives.
After this operation, 13.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://security.debian.org/debian-security bullseye-security/main amd64 nginx-common all 1.18.0-6.1+deb11u3 [126 kB]
Get:2 http://deb.debian.org/debian bullseye/main amd64 geoip-database all 20191224-3 [3,032 kB]
Get:3 http://security.debian.org/debian-security bullseye-security/main amd64 libnginx-mod-http-geoip amd64 1.18.0-6.1+deb11u3 [98.4 kB]
Get:4 http://security.debian.org/debian-security bullseye-security/main amd64 libnginx-mod-http-image-filter amd64 1.18.0-6.1+deb11u3 [102 kB]
Get:5 http://security.debian.org/debian-security bullseye-security/main amd64 libnginx-mod-http-xslt-filter amd64 1.18.0-6.1+deb11u3 [100 kB]
Get:6 http://security.debian.org/debian-security bullseye-security/main amd64 libnginx-mod-mail amd64 1.18.0-6.1+deb11u3 [129 kB]
Get:7 http://security.debian.org/debian-security bullseye-security/main amd64 libnginx-mod-stream amd64 1.18.0-6.1+deb11u3 [154 kB]
Get:8 http://security.debian.org/debian-security bullseye-security/main amd64 libnginx-mod-stream-geoip amd64 1.18.0-6.1+deb11u3 [97.7 kB]
Get:9 http://security.debian.org/debian-security bullseye-security/main amd64 nginx-core amd64 1.18.0-6.1+deb11u3 [515 kB]
Get:10 http://security.debian.org/debian-security bullseye-security/main amd64 nginx all 1.18.0-6.1+deb11u3 [92.9 kB]
Get:11 http://deb.debian.org/debian bullseye/main amd64 libgeoip1 amd64 1.6.12-7 [92.5 kB]
Fetched 4,541 kB in 1s (4,332 kB/s)
Preconfiguring packages ...
Selecting previously unselected package geoip-database.
(Reading database ... 142102 files and directories currently installed.)
Preparing to unpack .../00-geoip-database_20191224-3_all.deb ...
Unpacking geoip-database (20191224-3) ...
Selecting previously unselected package libgeoip1:amd64.
Preparing to unpack .../01-libgeoip1_1.6.12-7_amd64.deb ...
Unpacking libgeoip1:amd64 (1.6.12-7) ...
Selecting previously unselected package nginx-common.
Preparing to unpack .../02-nginx-common_1.18.0-6.1+deb11u3_all.deb ...
Unpacking nginx-common (1.18.0-6.1+deb11u3) ...
Selecting previously unselected package libnginx-mod-http-geoip.
Preparing to unpack .../03-libnginx-mod-http-geoip_1.18.0-6.1+deb11u3_amd64.deb ...
Unpacking libnginx-mod-http-geoip (1.18.0-6.1+deb11u3) ...
Selecting previously unselected package libnginx-mod-http-image-filter.
Preparing to unpack .../04-libnginx-mod-http-image-filter_1.18.0-6.1+deb11u3_amd64.deb ...
Unpacking libnginx-mod-http-image-filter (1.18.0-6.1+deb11u3) ...
Selecting previously unselected package libnginx-mod-http-xslt-filter.
Preparing to unpack .../05-libnginx-mod-http-xslt-filter_1.18.0-6.1+deb11u3_amd64.deb ...
Unpacking libnginx-mod-http-xslt-filter (1.18.0-6.1+deb11u3) ...
Selecting previously unselected package libnginx-mod-mail.
Preparing to unpack .../06-libnginx-mod-mail_1.18.0-6.1+deb11u3_amd64.deb ...
Unpacking libnginx-mod-mail (1.18.0-6.1+deb11u3) ...
Selecting previously unselected package libnginx-mod-stream.
Preparing to unpack .../07-libnginx-mod-stream_1.18.0-6.1+deb11u3_amd64.deb ...
Unpacking libnginx-mod-stream (1.18.0-6.1+deb11u3) ...
Selecting previously unselected package libnginx-mod-stream-geoip.
Preparing to unpack .../08-libnginx-mod-stream-geoip_1.18.0-6.1+deb11u3_amd64.deb ...
Unpacking libnginx-mod-stream-geoip (1.18.0-6.1+deb11u3) ...
Selecting previously unselected package nginx-core.
Preparing to unpack .../09-nginx-core_1.18.0-6.1+deb11u3_amd64.deb ...
Unpacking nginx-core (1.18.0-6.1+deb11u3) ...
Selecting previously unselected package nginx.
Preparing to unpack .../10-nginx_1.18.0-6.1+deb11u3_all.deb ...
Unpacking nginx (1.18.0-6.1+deb11u3) ...
Setting up nginx-common (1.18.0-6.1+deb11u3) ...

Step 3: Next start and enable the Nginx service by using the below command.

root@debian:~# systemctl start nginx
root@debian:~# systemctl enable nginx
Synchronizing state of nginx.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable nginx

Step 4: Check the status from Nginx service by using the below command.

root@debian:~# systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2023-07-04 18:07:03 CDT; 39s ago
       Docs: man:nginx(8)
   Main PID: 14817 (nginx)
      Tasks: 2 (limit: 4623)
     Memory: 2.5M
        CPU: 26ms
     CGroup: /system.slice/nginx.service
             ├─14817 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             └─14818 nginx: worker process
Jul 04 18:07:03 debian systemd[1]: Starting A high performance web server and a reverse proxy server...

Step 5: Make the Document Root Directory by using the below command.

root@debian:~# mkdir /var/www/test1.com

Step 6: Create the index.html in Document Root Directory by using the below command.

root@debian:~# vi /var/www/test1.com/index.html
<!DOCTYPE html>
<html>
<body>
<h1>Welcome to linuxhelp</h1>
</body>
</html>

Step 7: Give Ownership to the directory by using the below command

root@debian:~# chown -R www-data. /var/www/test1.com/

Step 8: Create Server Block in the following location by using the below command.

root@debian:~# vim /etc/nginx/sites-available/test1.com
server {
listen 80;
listen [::]:80;
root /var/www/test1.com;
index index.html index.htm index.nginx-debian.html;
server_name test1.com www.test1.com;
location /
    { try_files $uri $uri/ =404;

  }
}

Step 9: Create symbolic links to enable the site by using the below command.

root@debian:~# ln -s /etc/nginx/sites-available/test1.com /etc/nginx/sites-enabled/test1.com

Step 10: Edit the Host Entry for test1.com by using the below command.

root@debian:~# vim /etc/hosts
127.0.0.1       localhost
192.168.6.131   debian
127.0.0.1       www.test1.com
The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Step 11: Restart the Nginx by using the below command.

root@debian:~# systemctl restart nginx

Step 12: Finally go to the browser and browse Ping by server block’s domain name in web browser as shown in the below image.

snap 1

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to install and configure nginx on Debian 11.4. Your feedback is much welcome...

Tags:
gabriel
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What is the speciality of Nginx?

A

Nginx is built to offer low memory usage and high concurrency.

Q

How many load-balancing methods are supported by Nginx?

A

Nginx supports 3 methods that are round-robin, least-connected, and ip-hash.

Q

Who is using Nginx?

A

Some high-profile companies using Nginx include Autodesk, Atlassian, Intuit, T-Mobile, GitLab, DuckDuckGo, Microsoft, IBM, Google, Adobe, Salesforce, VMWare, Xerox, LinkedIn, Cisco, Facebook, Target, Citrix Systems, Twitter, Apple, Intel, and many more

Q

Is Nginx better than Apache?

A

Nginx performs 2.5 times faster than Apache, According to a benchmark test performed by running up to 1,000 simultaneous connections.

Q

Is Nginx an open-source server?

A

Yes, it is free of cost.

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Elijah ?
Remote Desktop Connection Has Stopped Working

When accessing my remote machine server using remote desktop on a windows machine I am getting this error

forum (1)

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.