ServerHandbook live check: run log
------------------------------------------------------------------------------
Check scripts/live/checks/install-nginx-ubuntu-24-04.mjs (sha256 1fe70e7c46f7ded8d644b189fcd85a93b0ea68d0c98809dfa0e407b4e67f0933)
Ran at 2026-11-11T23:52:52Z (113 s)
Result PASS, all 48 claims held
Tested on
System Ubuntu 24.04.5 LTS
Kernel 6.8.0-147-generic
Package nginx 1.24.0-2ubuntu7.19
Package nginx-common 1.24.0-2ubuntu7.19
Package ufw 0.36.2-6
Setup A fresh Ubuntu 24.04 server from Ubuntu’s cloud image with ufw on and SSH allowed, reached over SSH as a sudo user; the page tested from a second machine and a browser.
Every version above was read from the server at run time. Passwords used on the
throwaway test server are shown as [password]. How we test: https://serverhandbook.com/how-we-test
------------------------------------------------------------------------------
Claims (48), each with what the run saw
------------------------------------------------------------------------------
1. ok a bare Ubuntu 24.04 server box (web-server) starts
2. ok (setup) ufw is on with SSH allowed, as after the UFW article
| Status: active
|
| To Action From
| -- ------ ----
| OpenSSH ALLOW Anywhere
| OpenSSH (v6) ALLOW Anywhere (v6)
3. ok apt update reads the package lists
| en [340 B]
| Get:51 http://archive.ubuntu.com/ubuntu noble-backports/multiverse amd64 Components [212 B]
| Get:52 http://archive.ubuntu.com/ubuntu noble-backports/multiverse amd64 c-n-f Metadata [116 B]
| Fetched 38.2 MB in 22s (1759 kB/s)
| Reading package lists... Done
| Building dependency tree... Done
| Reading state information... Done
| 42 packages can be upgraded. Run 'apt list --upgradable' to see them.
4. ok apt installs nginx from Ubuntu’s own repository: "Setting up nginx (1.24.0…"
| this operation, 1602 kB of additional disk space will be used.
| Get:1 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 nginx-common all 1.24.0-2ubuntu7.19 [45.3 kB]
| Get:2 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 nginx amd64 1.24.0-2ubuntu7.19 [525 kB]
| Fetched 570 kB in 2s (274 kB/s)
| Preconfiguring packages ...
|
| Selecting previously unselected package nginx-common.
| (Reading database ... 75072 files and directories currently installed.)
| Preparing to unpack .../nginx-common_1.24.0-2ubuntu7.19_all.deb ...
| Unpacking nginx-common (1.24.0-2ubuntu7.19) ...
| Selecting previously unselected package nginx.
| Preparing to unpack .../nginx_1.24.0-2ubuntu7.19_amd64.deb ...
| Unpacking nginx (1.24.0-2ubuntu7.19) ...
| Setting up nginx-common (1.24.0-2ubuntu7.19) ...
| Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
| Setting up nginx (1.24.0-2ubuntu7.19) ...
| * Upgrading binary nginx [ OK ]
| Processing triggers for man-db (2.12.0-4build2) ...
| Processing triggers for ufw (0.36.2-6) ...
| Rules updated for profile 'OpenSSH'
| Skipped reloading firewall
|
| Scanning processes...
| Scanning linux images...
|
| Running kernel seems to be up-to-date.
|
| No services need to be restarted.
|
| No containers need to be restarted.
|
| No user sessions are running outdated binaries.
|
| No VM guests are running outdated hypervisor (qemu) binaries on this host.
5. ok nginx -v: "nginx version: nginx/1.24.0 (Ubuntu)"
| nginx version: nginx/1.24.0 (Ubuntu)
6. ok the install started nginx and enabled it at boot: "active (running)", "enabled"
| ● nginx.service - A high performance web server and a reverse proxy server
| Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: enabled)
| Active: active (running) since Wed 2026-11-11 23:53:45 UTC; 4s ago
| Docs: man:nginx(8)
| Process: 2409 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
| Process: 2411 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
| Main PID: 2441 (nginx)
| Tasks: 3 (limit: 2315)
| Memory: 2.4M (peak: 5.4M)
| CPU: 29ms
| CGroup: /system.slice/nginx.service
| ├─2441 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
| ├─2443 "nginx: worker process"
| └─2444 "nginx: worker process"
7. ok on the server itself the page answers "HTTP/1.1 200 OK", "Server: nginx/1.24.0 (Ubuntu)"
| HTTP/1.1 200 OK
| Server: nginx/1.24.0 (Ubuntu)
| Date: Wed, 11 Nov 2026 23:53:49 GMT
| Content-Type: text/html
| Content-Length: 615
| Last-Modified: Wed, 11 Nov 2026 23:53:44 GMT
| Connection: keep-alive
| ETag: "6af50008-267"
| Accept-Ranges: bytes
8. ok (probe) from outside there is no answer yet: ufw drops port 80
| 000
9. ok installing nginx added three ufw profiles: Nginx Full, Nginx HTTP, Nginx HTTPS
| Available applications:
| Nginx Full
| Nginx HTTP
| Nginx HTTPS
| OpenSSH
10. ok 'Nginx Full' opens ports 80 and 443
| Profile: Nginx Full
| Title: Web Server (Nginx, HTTP + HTTPS)
| Description: Small, but very powerful and efficient web server
|
| Ports:
| 80,443/tcp
11. ok ufw allow prints "Rule added" and "Rule added (v6)"
| Rule added
| Rule added (v6)
12. ok ufw status lists Nginx Full beside OpenSSH
| Status: active
|
| To Action From
| -- ------ ----
| OpenSSH ALLOW Anywhere
| Nginx Full ALLOW Anywhere
| OpenSSH (v6) ALLOW Anywhere (v6)
| Nginx Full (v6) ALLOW Anywhere (v6)
13. ok (probe) from outside the page now answers 200
| 200
14. ok (browser) the default page reads "Welcome to nginx!" (screenshot saved)
| .live-runs/install-nginx-ubuntu-24-04/default-page.png
15. ok the default page is /var/www/html/index.nginx-debian.html
| index.nginx-debian.html
16. ok tee prints the line it wrote
|
It works
17. ok nginx serves index.html at once, before the Debian page, with no reload
| It works
18. ok nginx.conf ships "# server_tokens off;" commented out
| 21: # server_tokens off;
19. ok nginx -t: "syntax is ok" and "test is successful"
| nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
| nginx: configuration file /etc/nginx/nginx.conf test is successful
20. ok reload prints nothing
21. ok after the reload the Server header is just "nginx", no version
| HTTP/1.1 200 OK
| Server: nginx
| Date: Wed, 11 Nov 2026 23:54:00 GMT
| Content-Type: text/html
| Content-Length: 18
| Last-Modified: Wed, 11 Nov 2026 23:53:58 GMT
| Connection: keep-alive
| ETag: "6af50016-12"
| Accept-Ranges: bytes
22. ok nginx -t WITHOUT sudo: "syntax is ok" and then "test failed" (it cannot write /run/nginx.pid)
| 2026/11/11 23:54:00 [warn] 3564#3564: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
| nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
| 2026/11/11 23:54:00 [emerg] 3564#3564: open() "/run/nginx.pid" failed (13: Permission denied)
| nginx: configuration file /etc/nginx/nginx.conf test failed
23. ok nginx -t finds the typo and names the file and line: "[emerg] … /etc/nginx/nginx.conf:NN", "test failed"
| 2026/11/11 23:54:00 [emerg] 3691#3691: invalid number of arguments in "server_tokens" directive in /etc/nginx/nginx.conf:26
| nginx: configuration file /etc/nginx/nginx.conf test failed
24. ok reload with the broken file fails…
| Job for nginx.service failed.
| See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.
25. ok …and the site keeps answering 200 on the old config
| HTTP/1.1 200 OK
| Server: nginx
| Date: Wed, 11 Nov 2026 23:54:01 GMT
| Content-Type: text/html
| Content-Length: 18
| Last-Modified: Wed, 11 Nov 2026 23:53:58 GMT
| Connection: keep-alive
| ETag: "6af50016-12"
| Accept-Ranges: bytes
26. ok (probe) from outside too
27. ok restart with the broken file fails…
| Job for nginx.service failed because the control process exited with error code.
| See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.
28. ok …and the site is DOWN: "Failed to connect to localhost port 80"
| curl: (7) Failed to connect to localhost port 80 after 0 ms: Couldn't connect to server
29. ok (probe) from outside: no answer
30. ok with the ; back nginx -t is successful again
| nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
| nginx: configuration file /etc/nginx/nginx.conf test is successful
31. ok (started again, the site answers)
32. ok the access log has a line per request: address, time, request, status, size, browser
| ::1 - - [11/Nov/2026:23:54:01 +0000] "HEAD / HTTP/1.1" 200 0 "-" "curl/8.5.0"
| 203.0.113.1 - - [11/Nov/2026:23:54:01 +0000] "GET / HTTP/1.1" 200 18 "-" "curl/8.5.0"
| 203.0.113.1 - - [11/Nov/2026:23:54:03 +0000] "GET / HTTP/1.1" 200 18 "-" "curl/8.5.0"
33. ok without sudo: "Permission denied" (the logs belong to www-data, group adm)
| tail: cannot open '/var/log/nginx/access.log' for reading: Permission denied
34. ok the journal keeps why a start failed (the emerg line from the broken restart)
| Nov 11 23:54:01 web-server systemd[1]: nginx.service: Failed with result 'exit-code'.
| Nov 11 23:54:01 web-server systemd[1]: Failed to start nginx.service - A high performance web server and a reverse proxy server.
| Nov 11 23:54:03 web-server systemd[1]: Starting nginx.service - A high performance web server and a reverse proxy server...
| Nov 11 23:54:03 web-server systemd[1]: Started nginx.service - A high performance web server and a reverse proxy server.
35. ok the server comes back after the reboot
| 14
36. ok nginx is running after the reboot with nothing done by hand
| active
37. ok (probe) and the page answers from outside: the ufw rule survived too
38. ok another program on port 80: nginx will not start
| Job for nginx.service failed because the control process exited with error code.
| See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.
39. ok the journal says "bind() to 0.0.0.0:80 failed (98: Address already in use)"
| Nov 11 23:54:24 web-server nginx[1309]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
| Nov 11 23:54:24 web-server nginx[1309]: nginx: [emerg] still could not bind()
| Nov 11 23:54:24 web-server systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
| Nov 11 23:54:24 web-server systemd[1]: nginx.service: Failed with result 'exit-code'.
| Nov 11 23:54:24 web-server systemd[1]: Failed to start nginx.service - A high performance web server and a reverse proxy server.
40. ok ss names the program holding port 80
| State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
| LISTEN 0 5 0.0.0.0:80 0.0.0.0:* users:(("python3",pid=1242,fd=3))
41. ok with port 80 free, nginx starts
42. ok (tested on) the box reports its OS, kernel and the version of 3 package(s)
| PRETTY_NAME="Ubuntu 24.04.5 LTS"
| VIRT=none
| KERNEL=6.8.0-147-generic
| PKG nginx 1.24.0-2ubuntu7.19
| PKG nginx-common 1.24.0-2ubuntu7.19
| PKG ufw 0.36.2-6
43. ok ufw delete removes both rules
| Rule deleted
| Rule deleted (v6)
44. ok apt remove nginx leaves nginx-common installed…
| ii nginx-common 1.24.0-2ubuntu7.19 all small, powerful, scalable web/proxy server - common files
45. ok …and /etc/nginx in place, so a reinstall gets your config back
| conf.d fastcgi_params koi-win modules-available nginx.conf scgi_params sites-enabled uwsgi_params
| fastcgi.conf koi-utf mime.types modules-enabled proxy_params sites-available snippets win-utf
46. ok (nginx stopped with the remove)
47. ok purging nginx-common deletes /etc/nginx and the logs
| ls: cannot access '/etc/nginx': No such file or directory
| ls: cannot access '/var/log/nginx': No such file or directory
48. ok your pages in /var/www/html are left alone
| index.html index.nginx-debian.html
------------------------------------------------------------------------------
Commands and what they printed (41)
------------------------------------------------------------------------------
$ sudo apt update
Get:1 http://security.ubuntu.com/ubuntu noble-security InRelease [126 kB]
Hit:2 http://archive.ubuntu.com/ubuntu noble InRelease
Get:3 http://archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB]
Get:4 http://security.ubuntu.com/ubuntu noble-security/main amd64 Packages [1186 kB]
Get:5 http://archive.ubuntu.com/ubuntu noble-backports InRelease [126 kB]
Get:6 http://archive.ubuntu.com/ubuntu noble/universe amd64 Packages [15.0 MB]
Get:7 http://security.ubuntu.com/ubuntu noble-security/main Translation-en [237 kB]
Get:8 http://security.ubuntu.com/ubuntu noble-security/main amd64 Components [46.4 kB]
Get:9 http://security.ubuntu.com/ubuntu noble-security/universe amd64 Packages [1228 kB]
Get:10 http://security.ubuntu.com/ubuntu noble-security/universe Translation-en [248 kB]
Get:11 http://security.ubuntu.com/ubuntu noble-security/universe amd64 Components [76.3 kB]
Get:12 http://security.ubuntu.com/ubuntu noble-security/universe amd64 c-n-f Metadata [24.2 kB]
Get:13 http://security.ubuntu.com/ubuntu noble-security/restricted amd64 Packages [1779 kB]
Get:14 http://security.ubuntu.com/ubuntu noble-security/restricted Translation-en [409 kB]
Get:15 http://security.ubuntu.com/ubuntu noble-security/multiverse amd64 Packages [45.4 kB]
Get:16 http://security.ubuntu.com/ubuntu noble-security/multiverse Translation-en [12.4 kB]
Get:17 http://security.ubuntu.com/ubuntu noble-security/multiverse amd64 Components [208 B]
Get:18 http://security.ubuntu.com/ubuntu noble-security/multiverse amd64 c-n-f Metadata [468 B]
Get:19 http://archive.ubuntu.com/ubuntu noble/universe Translation-en [5982 kB]
Get:20 http://archive.ubuntu.com/ubuntu noble/universe amd64 Components [3871 kB]
Get:21 http://archive.ubuntu.com/ubuntu noble/universe amd64 c-n-f Metadata [301 kB]
Get:22 http://archive.ubuntu.com/ubuntu noble/multiverse amd64 Packages [269 kB]
Get:23 http://archive.ubuntu.com/ubuntu noble/multiverse Translation-en [118 kB]
Get:24 http://archive.ubuntu.com/ubuntu noble/multiverse amd64 Components [35.0 kB]
Get:25 http://archive.ubuntu.com/ubuntu noble/multiverse amd64 c-n-f Metadata [8328 B]
Get:26 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages [1450 kB]
Get:27 http://archive.ubuntu.com/ubuntu noble-updates/main Translation-en [315 kB]
Get:28 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Components [181 kB]
Get:29 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Packages [1711 kB]
Get:30 http://archive.ubuntu.com/ubuntu noble-updates/universe Translation-en [344 kB]
Get:31 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Components [388 kB]
Get:32 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 c-n-f Metadata [34.9 kB]
Get:33 http://archive.ubuntu.com/ubuntu noble-updates/restricted amd64 Packages [1883 kB]
Get:34 http://archive.ubuntu.com/ubuntu noble-updates/restricted Translation-en [430 kB]
Get:35 http://archive.ubuntu.com/ubuntu noble-updates/multiverse amd64 Packages [50.7 kB]
Get:36 http://archive.ubuntu.com/ubuntu noble-updates/multiverse Translation-en [14.3 kB]
Get:37 http://archive.ubuntu.com/ubuntu noble-updates/multiverse amd64 Components [940 B]
Get:38 http://archive.ubuntu.com/ubuntu noble-updates/multiverse amd64 c-n-f Metadata [656 B]
Get:39 http://archive.ubuntu.com/ubuntu noble-backports/main amd64 Packages [40.6 kB]
Get:40 http://archive.ubuntu.com/ubuntu noble-backports/main Translation-en [9172 B]
Get:41 http://archive.ubuntu.com/ubuntu noble-backports/main amd64 Components [5744 B]
Get:42 http://archive.ubuntu.com/ubuntu noble-backports/main amd64 c-n-f Metadata [368 B]
Get:43 http://archive.ubuntu.com/ubuntu noble-backports/universe amd64 Packages [31.0 kB]
Get:44 http://archive.ubuntu.com/ubuntu noble-backports/universe Translation-en [18.6 kB]
Get:45 http://archive.ubuntu.com/ubuntu noble-backports/universe amd64 Components [12.6 kB]
Get:46 http://archive.ubuntu.com/ubuntu noble-backports/universe amd64 c-n-f Metadata [1588 B]
Get:47 http://archive.ubuntu.com/ubuntu noble-backports/restricted amd64 Components [212 B]
Get:48 http://archive.ubuntu.com/ubuntu noble-backports/restricted amd64 c-n-f Metadata [116 B]
Get:49 http://archive.ubuntu.com/ubuntu noble-backports/multiverse amd64 Packages [748 B]
Get:50 http://archive.ubuntu.com/ubuntu noble-backports/multiverse Translation-en [340 B]
Get:51 http://archive.ubuntu.com/ubuntu noble-backports/multiverse amd64 Components [212 B]
Get:52 http://archive.ubuntu.com/ubuntu noble-backports/multiverse amd64 c-n-f Metadata [116 B]
Fetched 38.2 MB in 22s (1759 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
42 packages can be upgraded. Run 'apt list --upgradable' to see them.
$ sudo apt install -y nginx
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
nginx-common
Suggested packages:
fcgiwrap nginx-doc ssl-cert
The following NEW packages will be installed:
nginx nginx-common
0 upgraded, 2 newly installed, 0 to remove and 42 not upgraded.
Need to get 570 kB of archives.
After this operation, 1602 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 nginx-common all 1.24.0-2ubuntu7.19 [45.3 kB]
Get:2 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 nginx amd64 1.24.0-2ubuntu7.19 [525 kB]
Fetched 570 kB in 2s (274 kB/s)
Preconfiguring packages ...
Selecting previously unselected package nginx-common.
(Reading database ... 75072 files and directories currently installed.)
Preparing to unpack .../nginx-common_1.24.0-2ubuntu7.19_all.deb ...
Unpacking nginx-common (1.24.0-2ubuntu7.19) ...
Selecting previously unselected package nginx.
Preparing to unpack .../nginx_1.24.0-2ubuntu7.19_amd64.deb ...
Unpacking nginx (1.24.0-2ubuntu7.19) ...
Setting up nginx-common (1.24.0-2ubuntu7.19) ...
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
Setting up nginx (1.24.0-2ubuntu7.19) ...
* Upgrading binary nginx [ OK ]
Processing triggers for man-db (2.12.0-4build2) ...
Processing triggers for ufw (0.36.2-6) ...
Rules updated for profile 'OpenSSH'
Skipped reloading firewall
Scanning processes...
Scanning linux images...
Running kernel seems to be up-to-date.
No services need to be restarted.
No containers need to be restarted.
No user sessions are running outdated binaries.
No VM guests are running outdated hypervisor (qemu) binaries on this host.
$ nginx -v
nginx version: nginx/1.24.0 (Ubuntu)
$ systemctl status nginx --no-pager
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: enabled)
Active: active (running) since Wed 2026-11-11 23:53:45 UTC; 4s ago
Docs: man:nginx(8)
Process: 2409 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 2411 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 2441 (nginx)
Tasks: 3 (limit: 2315)
Memory: 2.4M (peak: 5.4M)
CPU: 29ms
CGroup: /system.slice/nginx.service
├─2441 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
├─2443 "nginx: worker process"
└─2444 "nginx: worker process"
$ curl -I http://localhost
HTTP/1.1 200 OK
Server: nginx/1.24.0 (Ubuntu)
Date: Wed, 11 Nov 2026 23:53:49 GMT
Content-Type: text/html
Content-Length: 615
Last-Modified: Wed, 11 Nov 2026 23:53:44 GMT
Connection: keep-alive
ETag: "6af50008-267"
Accept-Ranges: bytes
$ sudo ufw app list
Available applications:
Nginx Full
Nginx HTTP
Nginx HTTPS
OpenSSH
$ sudo ufw app info 'Nginx Full'
Profile: Nginx Full
Title: Web Server (Nginx, HTTP + HTTPS)
Description: Small, but very powerful and efficient web server
Ports:
80,443/tcp
$ sudo ufw allow 'Nginx Full'
Rule added
Rule added (v6)
$ sudo ufw status
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
Nginx Full ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
Nginx Full (v6) ALLOW Anywhere (v6)
$ ls /var/www/html
index.nginx-debian.html
$ echo 'It works
' | sudo tee /var/www/html/index.html
It works
$ curl http://localhost
It works
$ grep -n 'server_tokens' /etc/nginx/nginx.conf
21: # server_tokens off;
$ sudo sed -i 's/# server_tokens off;/server_tokens off;/' /etc/nginx/nginx.conf
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
$ sudo systemctl reload nginx
$ curl -I http://localhost
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 11 Nov 2026 23:54:00 GMT
Content-Type: text/html
Content-Length: 18
Last-Modified: Wed, 11 Nov 2026 23:53:58 GMT
Connection: keep-alive
ETag: "6af50016-12"
Accept-Ranges: bytes
$ nginx -t
2026/11/11 23:54:00 [warn] 3564#3564: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
2026/11/11 23:54:00 [emerg] 3564#3564: open() "/run/nginx.pid" failed (13: Permission denied)
nginx: configuration file /etc/nginx/nginx.conf test failed
$ sudo nginx -t
2026/11/11 23:54:00 [emerg] 3691#3691: invalid number of arguments in "server_tokens" directive in /etc/nginx/nginx.conf:26
nginx: configuration file /etc/nginx/nginx.conf test failed
$ sudo systemctl reload nginx
Job for nginx.service failed.
See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.
$ curl -I http://localhost
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 11 Nov 2026 23:54:01 GMT
Content-Type: text/html
Content-Length: 18
Last-Modified: Wed, 11 Nov 2026 23:53:58 GMT
Connection: keep-alive
ETag: "6af50016-12"
Accept-Ranges: bytes
$ sudo systemctl restart nginx
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.
$ curl -I http://localhost
curl: (7) Failed to connect to localhost port 80 after 0 ms: Couldn't connect to server
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
$ sudo systemctl start nginx
$ sudo tail -n 3 /var/log/nginx/access.log
::1 - - [11/Nov/2026:23:54:01 +0000] "HEAD / HTTP/1.1" 200 0 "-" "curl/8.5.0"
203.0.113.1 - - [11/Nov/2026:23:54:01 +0000] "GET / HTTP/1.1" 200 18 "-" "curl/8.5.0"
203.0.113.1 - - [11/Nov/2026:23:54:03 +0000] "GET / HTTP/1.1" 200 18 "-" "curl/8.5.0"
$ tail -n 3 /var/log/nginx/access.log
tail: cannot open '/var/log/nginx/access.log' for reading: Permission denied
$ sudo journalctl -u nginx -n 4 --no-pager -q
Nov 11 23:54:01 web-server systemd[1]: nginx.service: Failed with result 'exit-code'.
Nov 11 23:54:01 web-server systemd[1]: Failed to start nginx.service - A high performance web server and a reverse proxy server.
Nov 11 23:54:03 web-server systemd[1]: Starting nginx.service - A high performance web server and a reverse proxy server...
Nov 11 23:54:03 web-server systemd[1]: Started nginx.service - A high performance web server and a reverse proxy server.
$ sudo reboot
$ systemctl is-active nginx
active
$ sudo systemctl start nginx
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details.
$ sudo journalctl -u nginx -n 5 --no-pager -q
Nov 11 23:54:24 web-server nginx[1309]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
Nov 11 23:54:24 web-server nginx[1309]: nginx: [emerg] still could not bind()
Nov 11 23:54:24 web-server systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Nov 11 23:54:24 web-server systemd[1]: nginx.service: Failed with result 'exit-code'.
Nov 11 23:54:24 web-server systemd[1]: Failed to start nginx.service - A high performance web server and a reverse proxy server.
$ sudo ss -ltnp 'sport = :80'
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 5 0.0.0.0:80 0.0.0.0:* users:(("python3",pid=1242,fd=3))
$ sudo systemctl start nginx
$ sudo ufw delete allow 'Nginx Full'
Rule deleted
Rule deleted (v6)
$ sudo apt remove -y nginx
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
nginx-common
Use 'sudo apt autoremove' to remove it.
The following packages will be REMOVED:
nginx
0 upgraded, 0 newly installed, 1 to remove and 42 not upgraded.
After this operation, 1355 kB disk space will be freed.
(Reading database ... 75120 files and directories currently installed.)
Removing nginx (1.24.0-2ubuntu7.19) ...
Processing triggers for man-db (2.12.0-4build2) ...
$ dpkg -l 'nginx*' | grep ^ii
ii nginx-common 1.24.0-2ubuntu7.19 all small, powerful, scalable web/proxy server - common files
$ ls /etc/nginx
conf.d fastcgi_params koi-win modules-available nginx.conf scgi_params sites-enabled uwsgi_params
fastcgi.conf koi-utf mime.types modules-enabled proxy_params sites-available snippets win-utf
$ sudo apt purge -y nginx-common
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
nginx-common*
0 upgraded, 0 newly installed, 1 to remove and 42 not upgraded.
After this operation, 247 kB disk space will be freed.
(Reading database ... 75115 files and directories currently installed.)
Removing nginx-common (1.24.0-2ubuntu7.19) ...
(Reading database ... 75095 files and directories currently installed.)
Purging configuration files for nginx-common (1.24.0-2ubuntu7.19) ...
Processing triggers for ufw (0.36.2-6) ...
Rules updated for profile 'OpenSSH'
Skipped reloading firewall
$ ls /etc/nginx /var/log/nginx
ls: cannot access '/etc/nginx': No such file or directory
ls: cannot access '/var/log/nginx': No such file or directory
$ ls /var/www/html
index.html index.nginx-debian.html
------------------------------------------------------------------------------
The check's source (scripts/live/checks/install-nginx-ubuntu-24-04.mjs)
As it ran.
------------------------------------------------------------------------------
/**
* KB: Install Nginx on Ubuntu 24.04: install, check it runs, open the firewall and see the page from outside, put your
* own page in place, change the config safely (test, reload; why not restart), logs, start after a reboot, the
* "Address already in use" error, uninstall.
*
* The server is a fresh VM box from Ubuntu's cloud image, reached as the sudo user `deploy`, with ufw on and SSH
* allowed, as the UFW article leaves it (hidden setup; `allow`, not `limit`: the runner reconnects every 2 s while it waits for a reboot, which `limit` would block). "From outside" is real: the VM's port 80 is forwarded to
* 127.0.0.1:PROBE_PORT on the laptop, so every probe is a packet arriving on the server's network card, which ufw
* drops or lets through; the browser screenshot of the default page is taken through the same port. The program that
* holds port 80 in the "Address already in use" case is a stand-in (python3 -m http.server); on a real server it is
* usually Apache.
*/
import { spawnSync } from 'node:child_process'
import { mkdirSync } from 'node:fs'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import { chromium } from 'playwright'
import { annotate } from '../annotate.mjs'
import { rebootBox } from '../box.mjs'
import { PROBE_PORT } from '../box/vm.mjs'
import { bareBox, reportBox } from '../lib.mjs'
export const meta = {}
const SLUG = 'install-nginx-ubuntu-24-04'
const here = dirname(fileURLToPath(import.meta.url))
const shotDir = join(here, '..', '..', '..', '.live-runs', SLUG)
/** The HTTP status a browser on another machine gets ('000' = no answer: dropped or refused). */
const outside = () =>
spawnSync('curl', ['-s', '-o', '/dev/null', '-m', '6', '-w', '%{http_code}', `http://127.0.0.1:${PROBE_PORT}/`], { encoding: 'utf8' }).stdout
async function screenshotDefaultPage() {
mkdirSync(shotDir, { recursive: true })
const out = join(shotDir, 'default-page.png')
const browser = await chromium.launch()
try {
const page = await browser.newPage({ viewport: { width: 900, height: 520 } })
await page.goto(`http://127.0.0.1:${PROBE_PORT}/`, { waitUntil: 'load' })
const title = await page.locator('h1').first().textContent()
await annotate(page, ['box|h1|3'])
await page.screenshot({ path: out, clip: { x: 130, y: 0, width: 680, height: 220 } })
return { out, title }
} finally {
await browser.close()
}
}
const check = (ctx) =>
bareBox(ctx, async ({ sudoUser }) => {
const { run, L } = sudoUser()
L('sudo true') // a reader has used sudo before (earlier articles), so Ubuntu's first-sudo hint is not on their screen
// as the UFW article leaves the server: SSH allowed (rate-limited), ufw on
L('sudo ufw allow OpenSSH && sudo ufw --force enable')
ctx.check('(setup) ufw is on with SSH allowed, as after the UFW article', /Status: active/.test(L('sudo ufw status')), L('sudo ufw status'))
// ── step 1: install ──────────────────────────────────────────────────────────────────────
const upd = run('sudo apt update', { id: 'apt-update', timeout: 600000 })
ctx.check('apt update reads the package lists', upd.exit === 0 && /Reading package lists/.test(upd.out), upd.out.slice(-400))
const inst = run('sudo apt install -y nginx', { id: 'apt-install', timeout: 900000 })
ctx.check('apt installs nginx from Ubuntu’s own repository: "Setting up nginx (1.24.0…"', inst.exit === 0 && /Setting up nginx \(1\.24\.0/.test(inst.out), inst.out.slice(-1500))
const v = run('nginx -v', { id: 'version' })
ctx.check('nginx -v: "nginx version: nginx/1.24.0 (Ubuntu)"', /^nginx version: nginx\/1\.24\.0 \(Ubuntu\)$/.test(v.out), v.out)
// ── step 2: it runs ──────────────────────────────────────────────────────────────────────
const st = run('systemctl status nginx --no-pager', { id: 'status' })
ctx.check('the install started nginx and enabled it at boot: "active (running)", "enabled"', /Active: active \(running\)/.test(st.out) && /nginx\.service; enabled;/.test(st.out), st.out)
const head = run('curl -I http://localhost', { id: 'curl-local' })
ctx.check('on the server itself the page answers "HTTP/1.1 200 OK", "Server: nginx/1.24.0 (Ubuntu)"', /^HTTP\/1\.1 200 OK/.test(head.out) && /Server: nginx\/1\.24\.0 \(Ubuntu\)/.test(head.out), head.out)
// ── step 3: firewall ─────────────────────────────────────────────────────────────────────
const blocked = outside()
ctx.check('(probe) from outside there is no answer yet: ufw drops port 80', blocked === '000', blocked)
const apps = run('sudo ufw app list', { id: 'ufw-apps' })
ctx.check('installing nginx added three ufw profiles: Nginx Full, Nginx HTTP, Nginx HTTPS', /Nginx Full/.test(apps.out) && /Nginx HTTP\n/.test(apps.out) && /Nginx HTTPS/.test(apps.out), apps.out)
const info = run("sudo ufw app info 'Nginx Full'", { id: 'ufw-info' })
ctx.check("'Nginx Full' opens ports 80 and 443", /80,443\/tcp/.test(info.out), info.out)
const allow = run("sudo ufw allow 'Nginx Full'", { id: 'ufw-allow' })
ctx.check('ufw allow prints "Rule added" and "Rule added (v6)"', allow.out === 'Rule added\nRule added (v6)', allow.out)
const ufs = run('sudo ufw status', { id: 'ufw-status' })
ctx.check('ufw status lists Nginx Full beside OpenSSH', /Nginx Full\s+ALLOW\s+Anywhere/.test(ufs.out) && /OpenSSH\s+ALLOW/.test(ufs.out), ufs.out)
const open = outside()
ctx.check('(probe) from outside the page now answers 200', open === '200', open)
const shot = await screenshotDefaultPage()
ctx.check('(browser) the default page reads "Welcome to nginx!" (screenshot saved)', shot.title === 'Welcome to nginx!', `.live-runs/${SLUG}/default-page.png`)
// ── step 4: your own page ────────────────────────────────────────────────────────────────
const ls = run('ls /var/www/html', { id: 'ls-html' })
ctx.check('the default page is /var/www/html/index.nginx-debian.html', ls.out === 'index.nginx-debian.html', ls.out)
const tee = run("echo 'It works
' | sudo tee /var/www/html/index.html", { id: 'own-page' })
ctx.check('tee prints the line it wrote', tee.out === 'It works
', tee.out)
const own = run('curl http://localhost', { id: 'curl-own' })
ctx.check('nginx serves index.html at once, before the Debian page, with no reload', own.out.endsWith('It works
'), own.out)
// ── step 5: change the config safely ─────────────────────────────────────────────────────
const tok = run("grep -n 'server_tokens' /etc/nginx/nginx.conf", { id: 'tokens-grep' })
ctx.check('nginx.conf ships "# server_tokens off;" commented out', /\d+:\s*# server_tokens off;/.test(tok.out), tok.out)
run("sudo sed -i 's/# server_tokens off;/server_tokens off;/' /etc/nginx/nginx.conf", { id: 'tokens-sed' })
const t1 = run('sudo nginx -t', { id: 'test-ok' })
ctx.check('nginx -t: "syntax is ok" and "test is successful"', t1.exit === 0 && /syntax is ok/.test(t1.out) && /test is successful/.test(t1.out), t1.out)
const rl = run('sudo systemctl reload nginx', { id: 'reload' })
ctx.check('reload prints nothing', rl.exit === 0 && rl.out === '', rl.out)
const h2 = run('curl -I http://localhost', { id: 'curl-tokens' })
ctx.check('after the reload the Server header is just "nginx", no version', /^Server: nginx\r?$/m.test(h2.out), h2.out)
const nosudo = run('nginx -t', { id: 'test-nosudo' })
ctx.check('nginx -t WITHOUT sudo: "syntax is ok" and then "test failed" (it cannot write /run/nginx.pid)', nosudo.exit !== 0 && /syntax is ok/.test(nosudo.out) && /open\(\) "\/run\/nginx\.pid" failed \(13: Permission denied\)/.test(nosudo.out) && /test failed/.test(nosudo.out), nosudo.out)
// a typo: the ; dropped from that line (hidden edit, as a reader's mistake)
L("sudo sed -i 's/server_tokens off;/server_tokens off/' /etc/nginx/nginx.conf")
const t2 = run('sudo nginx -t', { id: 'test-bad' })
ctx.check('nginx -t finds the typo and names the file and line: "[emerg] … /etc/nginx/nginx.conf:NN", "test failed"', t2.exit !== 0 && /\[emerg\].*\/etc\/nginx\/nginx\.conf:\d+/.test(t2.out) && /test failed/.test(t2.out), t2.out)
const rl2 = run('sudo systemctl reload nginx', { id: 'reload-bad' })
ctx.check('reload with the broken file fails…', rl2.exit !== 0 && /Job for nginx\.service failed/.test(rl2.out), rl2.out)
const still = run('curl -I http://localhost', { id: 'curl-still' })
ctx.check('…and the site keeps answering 200 on the old config', /^HTTP\/1\.1 200 OK/.test(still.out), still.out)
ctx.check('(probe) from outside too', outside() === '200', '')
const rs = run('sudo systemctl restart nginx', { id: 'restart-bad' })
ctx.check('restart with the broken file fails…', rs.exit !== 0 && /control process exited with error code/.test(rs.out), rs.out)
const down = run('curl -I http://localhost', { id: 'curl-down' })
ctx.check('…and the site is DOWN: "Failed to connect to localhost port 80"', /Failed to connect to localhost port 80/.test(down.out), down.out)
ctx.check('(probe) from outside: no answer', outside() === '000', '')
L("sudo sed -i 's/server_tokens off$/server_tokens off;/' /etc/nginx/nginx.conf")
const t3 = run('sudo nginx -t', { id: 'test-fixed' })
ctx.check('with the ; back nginx -t is successful again', t3.exit === 0 && /test is successful/.test(t3.out), t3.out)
run('sudo systemctl start nginx', { id: 'start-fixed' })
ctx.check('(started again, the site answers)', outside() === '200', '')
// ── logs ─────────────────────────────────────────────────────────────────────────────────
const acc = run('sudo tail -n 3 /var/log/nginx/access.log', { id: 'access-log' })
ctx.check('the access log has a line per request: address, time, request, status, size, browser', /"(GET|HEAD) \/ HTTP\/1\.1" 200 \d+ "-" "/.test(acc.out), acc.out)
const noread = run('tail -n 3 /var/log/nginx/access.log', { id: 'access-nosudo' })
ctx.check('without sudo: "Permission denied" (the logs belong to www-data, group adm)', /Permission denied/.test(noread.out), noread.out)
const why = run('sudo journalctl -u nginx -n 4 --no-pager -q', { id: 'journal' })
ctx.check('the journal keeps why a start failed (the emerg line from the broken restart)', /\[emerg\]/.test(why.out) || /Failed to start nginx\.service/.test(L('sudo journalctl -u nginx --no-pager -q')), why.out)
// ── reboot: it comes back by itself ──────────────────────────────────────────────────────
const secs = rebootBox()
ctx.capture('sudo reboot', '', { id: 'reboot' })
ctx.check('the server comes back after the reboot', typeof secs === 'number', String(secs))
const en = run('systemctl is-active nginx', { id: 'after-reboot' })
ctx.check('nginx is running after the reboot with nothing done by hand', en.out === 'active', en.out)
ctx.check('(probe) and the page answers from outside: the ufw rule survived too', outside() === '200', '')
// ── "Address already in use" ─────────────────────────────────────────────────────────────
L('sudo systemctl stop nginx')
L('sudo nohup python3 -m http.server 80 >/dev/null 2>&1 & sleep 2')
const busy = run('sudo systemctl start nginx', { id: 'busy-start' })
ctx.check('another program on port 80: nginx will not start', busy.exit !== 0 && /control process exited with error code/.test(busy.out), busy.out)
const bj = run('sudo journalctl -u nginx -n 5 --no-pager -q', { id: 'busy-journal' })
ctx.check('the journal says "bind() to 0.0.0.0:80 failed (98: Address already in use)"', /bind\(\) to 0\.0\.0\.0:80 failed \(98: Address already in use\)/.test(bj.out), bj.out)
const who = run("sudo ss -ltnp 'sport = :80'", { id: 'busy-ss' })
ctx.check('ss names the program holding port 80', /0\.0\.0\.0:80 .*users:\(\("python3"/.test(who.out), who.out)
L("sudo pkill -f 'http.server 80'; sleep 1")
const ok = run('sudo systemctl start nginx', { id: 'busy-fixed' })
ctx.check('with port 80 free, nginx starts', ok.exit === 0 && L('systemctl is-active nginx') === 'active', ok.out)
reportBox(
ctx,
L,
'A fresh Ubuntu 24.04 server from Ubuntu’s cloud image with ufw on and SSH allowed, reached over SSH as a sudo user; the page tested from a second machine and a browser.',
['nginx', 'nginx-common', 'ufw'],
)
// ── uninstall ────────────────────────────────────────────────────────────────────────────
// the firewall rule first: the 'Nginx Full' profile file goes with nginx-common
const del = run("sudo ufw delete allow 'Nginx Full'", { id: 'ufw-delete' })
ctx.check('ufw delete removes both rules', /Rule deleted/.test(del.out), del.out)
run('sudo apt remove -y nginx', { id: 'remove', timeout: 600000 })
const left = run("dpkg -l 'nginx*' | grep ^ii", { id: 'remove-left' })
ctx.check('apt remove nginx leaves nginx-common installed…', /^ii\s+nginx-common\s/m.test(left.out) && !/^ii\s+nginx\s/m.test(left.out), left.out)
const conf = run('ls /etc/nginx', { id: 'remove-etc' })
ctx.check('…and /etc/nginx in place, so a reinstall gets your config back', /nginx\.conf/.test(conf.out), conf.out)
ctx.check('(nginx stopped with the remove)', L('systemctl is-active nginx') !== 'active' && outside() === '000', '')
run('sudo apt purge -y nginx-common', { id: 'purge', timeout: 600000 })
const gone = run('ls /etc/nginx /var/log/nginx', { id: 'purge-gone' })
ctx.check('purging nginx-common deletes /etc/nginx and the logs', /cannot access '\/etc\/nginx'/.test(gone.out) && /cannot access '\/var\/log\/nginx'/.test(gone.out), gone.out)
const www = run('ls /var/www/html', { id: 'purge-www' })
ctx.check('your pages in /var/www/html are left alone', www.out.includes('index.html'), www.out)
})
export default check