I guess you will have to put that setting back and manually pick and choose which files to keep enabled or disable.
OR move them to another path if they are not enabled links.
But one is clearly a backup of the other - both should not be used.
You can delete the .bak file or move it to another location (where it won't be used).
root@ip-172-31-47-28:~# sudo systemctl restart nginx
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
root@ip-172-31-47-28:~#
root@ip-172-31-47-28:~# sudo systemctl status nginx.service
● nginx.service - nginx - high performance web server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: en
Active: failed (Result: exit-code) since Mon 2021-10-25 20:37:28 UTC; 27min a
Docs: nginx documentation
Process: 12356 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited
Main PID: 5908 (code=exited, status=0/SUCCESS)
Oct 25 20:37:27 ip-172-31-47-28 nginx[12356]: nginx: [emerg] bind() to [::]:443
Oct 25 20:37:28 ip-172-31-47-28 nginx[12356]: nginx: [emerg] bind() to 0.0.0.0:8
Oct 25 20:37:28 ip-172-31-47-28 nginx[12356]: nginx: [emerg] bind() to [::]:80 f
Oct 25 20:37:28 ip-172-31-47-28 nginx[12356]: nginx: [emerg] bind() to 0.0.0.0:4
Oct 25 20:37:28 ip-172-31-47-28 nginx[12356]: nginx: [emerg] bind() to [::]:443
Oct 25 20:37:28 ip-172-31-47-28 nginx[12356]: nginx: [emerg] still could not bin
Oct 25 20:37:28 ip-172-31-47-28 systemd[1]: nginx.service: Control process exite
Oct 25 20:37:28 ip-172-31-47-28 systemd[1]: Failed to start nginx - high perform
Oct 25 20:37:28 ip-172-31-47-28 systemd[1]: nginx.service: Unit entered failed s
Oct 25 20:37:28 ip-172-31-47-28 systemd[1]: nginx.service: Failed with result 'e
lines 1-17/17 (END)
I know you tried the netstat earlier and it showed nginx was listening. But, when you tried to restart it the message says it could not start due to bind failures to those ports.
The stop nginx I suggest should not do anything. But please post results anyway.
Ok, well, that is interesting. The nginx master listening on those ports has a PID of 6063 which is the same PID that showed when you used that command earlier. It appears to be stuck. Yet, it did not respond to the stop command you just tried.
I am not sure how to clear that up. Maybe restart the server. If you are using EC2 you could use its console to Restart or even Stop/Start the Instance.
At least I think we have identified why the bind errors occur. Now it is a matter of getting your system back in a good state.
root@ip-172-31-47-28:~# sudo systemctl start nginx
root@ip-172-31-47-28:~# sudo systemctl status nginx.service
● nginx.service - nginx - high performance web server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: en
Active: active (running) since Mon 2021-10-25 21:32:43 UTC; 1min 22s ago
Docs: nginx documentation
Main PID: 1428 (nginx)
Tasks: 3
Memory: 31.9M
CPU: 53ms
CGroup: /system.slice/nginx.service
├─1428 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.con
└─1429 nginx: worker process
Oct 25 21:32:43 ip-172-31-47-28 systemd[1]: Starting nginx - high performance we
Oct 25 21:32:43 ip-172-31-47-28 systemd[1]: Started nginx - high performance web
Oct 25 21:33:49 ip-172-31-47-28 systemd[1]: Started nginx - high performance web
lines 1-15/15 (END)