Why does running “apachectl -k start” not work, but “sudo apachectl -k start” does?

StackOverflow https://stackoverflow.com/questions/904606

  •  05-09-2019
  •  | 
  •  

Question

I'm working on my OS X with the default installation of Apache. For some reason, when I run the "apachectl" command without the "sudo" I get "no listening sockets available / unable to open logs." I'm guessing this is a permissioning thing, so can someone help me out? I'm using Apache 2.2.

Also, side question, where the the Apache script file that is basically the "exe" that linux executes? I'm trying to intergrate my server with Aptana Studio, and it requires the path to the Apache install. I know in Windows, this would be "C:\path\to\httpd.exe", but I don't know how this works in linux.

Was it helpful?

Solution

Is your server listening on port 80? (Usually) only root is allowed to open ports below 1024. Hence the need for sudo.

As you can see, lots of people wonder how to get around this. One possible solution is to perform port-forwarding on your router. (I'm assuming here that you are behind a router...). Then incoming connections on port 80 can be forwarded to e.g. port 8080. Thus only locally does one need to connect to port 8080. (There may be more elegant solutions... somebody else will post them.)

OTHER TIPS

I think generally (on both OS X and Linux - I'm not sure which one you're referring to) the httpd binary is located at: /usr/sbin/httpd

If you need to be able to restart Apache, and you can't do so as root (for whatever reason..), then you may have to settle for a non 'well known' port.

try this

(with php) $a = shell_exec('sudo -u root -S /etc/init.d/apache2 restart < /home/$user/passfile');

password should stored in passfile

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top