I got a problem which I have been trying to fix for a few days now and I don't know what to do, have been looking for answers but all of those I found didn't help me.
I am kinda new here and I really hope that someone can help me. You can tell me which informations I need to give in hope for finding a solution.
$ systemctl status nginx.service
nginx.service - Startup script for nginx service
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2016-03-08 13:23:35 GMT; 2min 20s ago
Mar 08 13:23:33 startdedicated.com nginx[8315]: nginx: [emerg] bind() to ------------ f...e)
Mar 08 13:23:33 startdedicated.com nginx[8315]: nginx: [emerg] bind() to ----- f...e)
Mar 08 13:23:34 startdedicated.com nginx[8315]: nginx: [emerg] bind() to ----- f...e)
Mar 08 13:23:34 startdedicated.com nginx[8315]: nginx: [emerg] bind() to ----- f...e)
Mar 08 13:23:35 startdedicated.com nginx[8315]: nginx: [emerg] bind() to ----- f...e)
Mar 08 13:23:35 .startdedicated.com nginx[8315]: nginx: [emerg] still could not bind()
Mar 08 13:23:35 startdedicated.com systemd[1]: nginx.service: control process exited, code=...=1
Mar 08 13:23:35 startdedicated.com systemd[1]: Failed to start Startup script for nginx service.
Mar 08 13:23:35 startdedicated.com systemd[1]: Unit nginx.service entered failed state.
Mar 08 13:23:35 startdedicated.com systemd[1]: nginx.service failed.
For my case, I need to run
It will check if Nginx configuration is correct or not, if not, it will show you which configuration causes the error.
Then you need to go to
/etc/nginx/sites-available
to fix the broken configuration.After that, you can restart Nginx without any problem.
In my case, nginx was not able to open the log file which is located here
/var/log/nginx/error.log
This was because I had deleted the log directory to free up space in root (which turned out to be stupid)
I then created a log folder in var and an nginx folder in log.
Then simply run
sudo service nginx start
Check df -h if you are under centOS system
change the port may help as 80 port is already using somewhere
Change the port:
And then restart the nginx server
Try to debug with command:
Which outputs something like:
And fix those warnings
Then restart nginx
Try set a user in nginx.conf, maybe that's why he can not start the service: