Here is my ngnix.conf .
user www-data; worker_processes 4; pid /run/nginx.pid; events { worker_connections 768; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; gzip on; gzip_disable "msie6"; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; } server { listen 8080; server_name localhost; index index.html index.htm index.php; root /var/www/html; } To input the command after edited the file.
service nginx restart Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.
systemctl -l status nginx.service nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled) Active: failed (Result: exit-code) since Wed 2015-09-16 15:31:14 HKT; 5s ago Sep 16 15:31:14 pengsir nginx[6133]: nginx: configuration file /etc/nginx/nginx.conf test failed I have fix the problem,new problem remain.
nginx -t nginx: [warn] conflicting server name "localhost" on 0.0.0.0:8080, ignored nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful root@pengsir:/home/debian8# service nginx start Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details. root@pengsir:/home/debian8# systemctl -l status nginx.service ● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled) Active: failed (Result: exit-code) since Wed 2015-09-16 17:37:54 HKT; 21s ago Process: 6030 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS) Process: 9636 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE) Process: 9634 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Main PID: 5908 (code=exited, status=0/SUCCESS) Sep 16 17:37:51 pengsir nginx[9636]: nginx: [warn] conflicting server name "localhost" on 0.0.0.0:8080, ignored Sep 16 17:37:51 pengsir nginx[9636]: nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use) Sep 16 17:37:52 pengsir nginx[9636]: nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use) Sep 16 17:37:52 pengsir nginx[9636]: nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use) Sep 16 17:37:53 pengsir nginx[9636]: nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use) Sep 16 17:37:53 pengsir nginx[9636]: nginx: [emerg] bind() to 0.0.0.0:8080 failed (98: Address already in use) Sep 16 17:37:54 pengsir nginx[9636]: nginx: [emerg] still could not bind() Sep 16 17:37:54 pengsir systemd[1]: nginx.service: control process exited, code=exited status=1 Sep 16 17:37:54 pengsir systemd[1]: Failed to start A high performance web server and a reverse proxy server. Sep 16 17:37:54 pengsir systemd[1]: Unit nginx.service entered failed state.
service nginx restart, is it placed at the bottom of your config file?servershould be insidehttpblock.nginx -tto check config. It will tell you exact error and where it occures