GrepBoard/Manuals
47 manuals ·

Install Nginx and set the server name

·Ubuntu 24.04.5 LTS · nginx 1.24.0·4 steps

Install Nginx from the Ubuntu repository, set the default site to your host name, then test the config and reload without dropping connections.

Install Nginx from the Ubuntu 24.04 repository and make the default site answer to your host name. The host name below is written as www.example.com.

[1] Install the package. It starts the service and enables it at boot by itself.

console
# apt-get install -y nginx# systemctl is-enabled nginxenabled# systemctl is-active nginxactive# nginx -vnginx version: nginx/1.24.0 (Ubuntu)

[2] Change server_name _; in the default site to your host name. The file is full of comments; find the server_name line.

/etc/nginx/sites-available/default
server {	listen 80 default_server;	listen [::]:80 default_server;	root /var/www/html;	index index.html index.htm index.nginx-debian.html;+	server_name www.example.com;

[3] Test the syntax, then reload. A reload keeps open connections, and if the test fails the running configuration stays as it was.

console
# nginx -tnginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful# systemctl reload nginx

[4] Request the page from the server itself. The Host header stands in for the host name.

console
$ curl -sI -H 'Host: www.example.com' http://localhost/HTTP/1.1 200 OKServer: nginx/1.24.0 (Ubuntu)Date: Mon, 19 Oct 2026 00:32:59 GMTContent-Type: text/htmlContent-Length: 615Last-Modified: Mon, 19 Oct 2026 00:32:47 GMTConnection: keep-aliveETag: "6ad5652f-267"Accept-Ranges: bytes

Analyze your Nginx log in the browser ↗ — nothing is uploaded.

#nginx#ubuntu#web