2

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. 
5
  • Let's clarify: this line: service nginx restart , is it placed at the bottom of your config file? Commented Sep 16, 2015 at 7:45
  • 1
    server should be inside http block. Commented Sep 16, 2015 at 7:54
  • 4
    Also use nginx -t to check config. It will tell you exact error and where it occures Commented Sep 16, 2015 at 7:55
  • 2
    Address already in use means that some program is already listening in that port, tomcat maybe? Try a sudo fuser 8080/tcp to detect which one is Commented Sep 16, 2015 at 9:49
  • kill the service ,problem solved. Commented Sep 16, 2015 at 9:52

3 Answers 3

1

You can see the binding 8080. You need to remove the Binding 8080 from the sites. Once you remove it restart the service

service nginx restart

Sign up to request clarification or add additional context in comments.

Comments

0

you have another process listening on port 80, in this case httpd. You'll need to stop that service first (and probably want to disable it on boot).

To stop Apache;

systemctl stop httpd 

To stop Apache starting on boot;

systemctl disable httpd 

and

proxy_pass https://<IP-OF-YOUR-SERVER>:8443; 

for demo

http://127.0.0.1:8069/web

Comments

0

if (apache and nginx) have both

Do you want to enable Angnix?

1-systemctl stop httpd

2-service nginx restart

3-service nginx status

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.