Question

how to handle it?

root@ubuntu-s-1vcpu-1gb-intel-sgp1-01:~# nginx -t -c /etc/nginx/nginx.conf
nginx: [emerg] unknown directive "        listen" in /etc/nginx/sites-enabled/dankerdan.my.id:2
nginx: configuration file /etc/nginx/nginx.conf test failed
root@ubuntu-s-1vcpu-1gb-intel-sgp1-01:~# sudo service nginx restart
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
root@ubuntu-s-1vcpu-1gb-intel-sgp1-01:~# nginx -t -c /etc/nginx/nginx.conf
nginx: [emerg] unknown directive "        listen" in /etc/nginx/sites-enabled/dankerdan.my.id:2
nginx: configuration file /etc/nginx/nginx.conf test failed
root@ubuntu-s-1vcpu-1gb-intel-sgp1-01:~# nginx -t
nginx: [emerg] unknown directive "        listen" in /etc/nginx/sites-enabled/dankerdan.my.id:2
nginx: configuration file /etc/nginx/nginx.conf test failed
root@ubuntu-s-1vcpu-1gb-intel-sgp1-01:~# sudo service nginx stop
root@ubuntu-s-1vcpu-1gb-intel-sgp1-01:~# sudo service nginx start
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
root@ubuntu-s-1vcpu-1gb-intel-sgp1-01:~# systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2022-12-22 20:37:20 WIB; 17s ago
    Process: 52174 ExecStartPre=/opt/nginx/sbin/nginx -t (code=exited, status=203/EXEC)
Dec 22 20:37:20 ubuntu-s-1vcpu-1gb-intel-sgp1-01 systemd[1]: Starting The nginx HTTP and reverse proxy server...
Dec 22 20:37:20 ubuntu-s-1vcpu-1gb-intel-sgp1-01 systemd[52174]: nginx.service: Failed to execute command: No such file or directoryDec 22 20:37:20 ubuntu-s-1vcpu-1gb-intel-sgp1-01 systemd[52174]: nginx.service: Failed at step EXEC spawning /opt/nginx/sbin/nginx:>Dec 22 20:37:20 ubuntu-s-1vcpu-1gb-intel-sgp1-01 systemd[1]: nginx.service: Control process exited, code=exited, status=203/EXEC
Dec 22 20:37:20 ubuntu-s-1vcpu-1gb-intel-sgp1-01 systemd[1]: nginx.service: Failed with result 'exit-code'.
Dec 22 20:37:20 ubuntu-s-1vcpu-1gb-intel-sgp1-01 systemd[1]: Failed to start The nginx HTTP and reverse proxy server.
lines 1-11/11 (END)__****__

Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
December 23, 2022

Hi there,

As reported by the nginx -t command you have a syntax error in your /etc/nginx/sites-enabled/dankerdan.my.id file. You need to edit that fie and remove the listen directive from line two.

Feel free to share the complete /etc/nginx/sites-enabled/dankerdan.my.id file here so I could advise you on what exactly needs to be changed!

For more information on how Nginx server blocks work, I would recommend this tutorial here:

https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04

Best,

Bobby