Amazon EC2 - Apache server restart problem

When I ran this command

sudo / etc / init.d / httpd restart

he gives below error

Stop httpd: [FAILED]

Launch httpd: (98) Address already exist: make_sock: could not bind to address [::]: 80 (98) Address is already used: make_sock: could not bind to address 0.0.0.0:80 there are no slots available for listening, shutdown Not managed to open magazines [FAILED]


i checked running programs on port 80 with

netstat -lnp | grep: 80 (displayed below)

tcp 0 0: 80: * LISTEN 21739 / httpd


why can't I stop apache stop using restart sudo / etc / init.d / httpd?

below teams work without problems

sudo apachectl stop

sudo apachectl start

I am using a Linux instance of amazon ec2

+8
linux apache amazon-ec2
source share
3 answers

I ran into this problem when I installed apache from source, but then tried to run

$ sudo /etc/init.d/httpd restart 

which used a pre-installed version of apache. The stop directive in the /etc/init.d/httpd file did not delete the httpd.pid file created when the original version of apache was launched.

To determine if this is also the cause of your problem, find the httpd.pid file that will be installed at startup

 $ sudo apachectl start 

If you installed from the source, and apache2 lives in / usr / local / apache 2, then the httpd.pid file must be created in / usr / local / apache 2 / logs. When you stop apache by running

 $ sudo apachectl stop 

This file must be deleted. Therefore, to check if the httpd.pid file caused your problem, run apache by calling

 $ sudo apachectl start 

and find the httpd.pid file. Then try stopping apache using

 $ sudo /etc/init.d/httpd stop 

If the source httpd.pid file is still present, that is why apache cannot start when you use

 $ sudo /etc/init.d/httpd start 

In order for my /etc/init.d/httpd file to work correctly, I explicitly put the apachectl call into the start and stop methods:

 #!/bin/bash # /etc/init.d/httpd # # Path to the apachectl script, server binary, and short-form for messages. apachectl=/usr/local/apache2/bin/apachectl httpd=/usr/local/apache2/bin/httpd pid=/usr/local/apache2/logs/httpd.pid prog=httpd RETVAL=0 start() { echo -n $"Starting $prog: " $apachectl -k start RETVAL=$? echo return $RETVAL } stop() { echo -n $"Stopping $prog: " $apachectl -k stop RETVAL=$? echo } 
+14
source share

I feel that it’s better to kill the process itself, find out the process identifier and kill it, and then make a new start, it should work fine

0
source share

I tried this and it works:

  • sudo fuser -k -n tcp 80
  • sudo service httpd start

Hope this helps you!

Greetings

0
source share

All Articles