networking - OSX, Failed to listen on 0.0.0.0:80 (reason: Permission denied)
2014-04
I'm on OSX Mavericks. I installed PHP 5.5 from http://php-osx.liip.ch/. When I go to localhost in a browser I get a page that says, "It Works!" which is not a page I created so I am not sure where it is located. Is this from the PHP install or just Apache?
When I open my IDE (PHPStorm) and run the website, it works if I use a port like 8080. If I set the port to 80, it fails and the IDE says:
/usr/local/php5/bin/php -S 0.0.0.0:80 -t /mywebsitepath/
Failed to listen on 0.0.0.0:80 (reason: Permission denied)
When I searched for that specific error, all I found was help for NGINX, but I am using Apache. What do I need to change to be able to run my code locally on port 80?
I want to do this so I can use localhost instead of localhost:8080.
Ports below 1024 are privileged, and cannot be bound to by anyone other than root. Since you can't run your IDE as root, I would set up an Nginx proxy going from port 80 to port 8080, should be easy to do, there are many tutorials =D
The IP 0.0.0.0 is reserved by the Ethernet Standards you can't use this, use 127.0.0.1 instead. But as I know you really don't need to enter a IP to tell the Server on what he should listen, for that you just need the Port.
I'm trying to track down a php issue with a tool that I'm trying to install, and have tracked it down, I believe, to a permissions issue with the filesystem, I believe...
I now have the following simple .php file:
<?php
system("/bin/ls");
?>
When I run this, I see the following error in /var/log/httpd/error_log:
sh: /bin/ls: Permission denied
If I change the php to run:
<?php
system("/bin/env");
?>
Then I see the output that I was expecting.
So it's not the execution that doesn't have permissions, it's what the executable is trying to read that is having problems.
(The tool I am trying to get working here is phplicensewatcher - a tool for keeping an eye on what is going on with various license management daemons)
Thanks
The first two thing I would check:
What user is PHP running under? If it's spawned by Apache, it is likely running as "nobody", "www" or "apache" depending on the version and configuration.
What directory are you trying to list? Check the permissions on that directory. Does the user PHP is running as have permission to access that directory?