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


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

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.