Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to set up an Amazon EC2 web server on the "Virtual Private Cloud". I'm using this instead of a standard EC2 instance because I needed to assign multiple public IPs and that necessitates the use of VPC.

Anyway, after much hoop jumping, I finally got the instance up and running and connected via SSH. I built the instance from an image I took of a standard webserver that is working fine. However, I don't appear to be able to start Apache:

# service httpd status
httpd is stopped
# service httpd start
Starting httpd: (98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
                                                           [FAILED]
# netstat -ltnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1243/sshd
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1275/sendmail
tcp        0      0 0.0.0.0:9306                0.0.0.0:*                   LISTEN      1225/searchd
tcp        0      0 0.0.0.0:9312                0.0.0.0:*                   LISTEN      1225/searchd
tcp        0      0 :::80                       :::*                        LISTEN      1289/httpd
tcp        0      0 :::22                       :::*                        LISTEN      1243/sshd
tcp        0      0 :::443                      :::*                        LISTEN      1289/httpd
# ps aux | grep httpd
root      1287  0.0  0.2 108476  1780 ?        S    21:17   0:00 /bin/bash /etc/rc3.d/S85httpd start
root      1288  0.0  0.2  11348  1332 ?        S    21:17   0:00 /bin/bash -c ulimit -S -c 0 >/dev/null 2>&1 ; /usr/sbin/httpd
root      1289  0.0  1.2 211888  7764 ?        S    21:17   0:00 /usr/sbin/httpd

So I'm a bit confused. Apache isn't running (as a service, and I've not set it to run any other ways), and I can't start the service, but isn't this saying that Apache IS running? Any ideas how to resolve?

Added 04/Dec/2012

Apache has been installed and set to start automatically on boot with chkconfig --levels 235 httpd on, which is why the httpd process is running on boot. However, when you enter service httpd status it was still reading as stopped and was unavailable through a web browser.

In order to actually restart Apache, it appears that you need to kill the process gracefully (kill -15 1289 works, where 1289 was the process ID) and then enter service httpd start. You can now start, stop, restart and reload Apache with no problem.

However, I wanted to be able to use the service command immediately, and further poking around led me to a conclusion that nobody could've realistically provided: One of the SSL keys requires a passphrase, and it couldn't be entered at boot (clearly), so the process was unable to start properly. I removed the passphrase (that we didn't really want, anyway) and rebooted. Now, when I check with service httpd status I get httpd dead but subsys locked. I have to delete /var/lock/subsys/httpd to get the process to start correctly again.

So, it felt like progress, but the process still doesn't start automatically.

Ideas, please?

share|improve this question
3  
Yes, it's saying Apache is running, because it is. Kill those processes and then restart it again, it should work. –  gparent Nov 29 '12 at 21:48
    
OK, apparently someone thinks "This question does not show any research effort; it is unclear or not useful". I accept that maybe it was a little unclear in that I'd originally stated that Apache was not running when clearly it is. What I meant was that it's not running as a service, which is how it was configured to run, so I don't understand how it's running or why. Yes, I killed the processes and that allowed me to start the service, but I don't understand why it's started already. Nor do I understand why it's like this every reboot. Any help? –  Ant The Knee Nov 29 '12 at 21:52
    
What struck me is that last three lines of the netstat result. In the AWS VPC Security Group, I have only allowed four TCP ports: 22, 80, 443 and 3306. MySQL isn't yet installed, so I'm not surprised to not see it in the list. Seeing httpd and sshd holding those particular ports leads me to believe that it's probably the AWS platform itself that's doing this, but only via VPC and not standard EC2 instances? –  Ant The Knee Nov 29 '12 at 22:03
    
AWS isn't doing anything. If the machine is listening on 22, it's because sshd is running, and we know Apache is running from your ps aux so that's likely what is causing 80 and 443. There are two sides here: the firewall (security group) associated with the instance, and then which ports are being opened by services on your machine. –  Tom Harrison Jr Nov 30 '12 at 13:43
    
Oh and to answer your second comment, apache and ssh are starting on reboot because they are set to do so in in /etc/init.d scripts. Depending on your distro, there are commands you can use to determine what starts on reboot -- chkconfig on CentOS and RHEL, for example. Apache will start and use the configuration specified under /etc/httpd in files like httpd.conf and others. –  Tom Harrison Jr Nov 30 '12 at 13:48

2 Answers 2

I'd say apache IS running, and you can see it in the display....netstat indicates that process 1289 is listening on port 80 and indeed the ps is showing this too. httpd is apache!

Thus you probably can simply kill -9 1289 (as root) and then restart.

share|improve this answer

tcp 0 0 :::80 :::* LISTEN 1289/httpd

Httpd is running, and has a process id of 1289. If for some unusual reason that isn't Apache and something else that is also named httpd, then you might be able to find more information with a command like lsof -n -p 1289.

You could probably just kill that process though.

share|improve this answer
    
Thanks for your answer. It is running, but isn't working, if you see what I mean? It's not accepting incoming requests. I have killed it and started it manually and it works fine. Turns out that it's because of a passphrased SSL certificate, but removing the passphrase just introduces a new fault. I've edited the original to elaborate further –  Ant The Knee Dec 4 '12 at 14:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.