5

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.

7
  • 3
    Since you get a page from localhost, then means some software on your computer is already using port 80. Two programs can't use the same port at the same time.
    – Ben Voigt
    Commented Jan 29, 2014 at 20:13
  • How can I see what is currently using it? I'm guessing it's something that happens at start-up.
    – Justin
    Commented Jan 29, 2014 at 20:15
  • For that, see Who is listening on a given TCP port on Mac OS X?
    – Ben Voigt
    Commented Jan 29, 2014 at 20:27
  • When I do sudo lsof -i TCP:80 | grep LISTEN I get no results.
    – Justin
    Commented Jan 29, 2014 at 20:38
  • you didn't turn off port number->name lookup, so it might be outputting TCP:http (I don't know about Mac lsof, but netstat on other OSes would). Check the output of just sudo lsof -i TCP to see what format it is in.
    – Ben Voigt
    Commented Jan 29, 2014 at 20:46

1 Answer 1

16

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

5
  • Or an Apache proxy, if you are more familiar with that. Nginx rocks though. Oh and since you have OSX's Apache running on port 80, you'll have to stop it (or use it as a proxy)
    – Yarek T
    Commented Jan 29, 2014 at 20:15
  • He could probably run his IDE as root.. ''sudo open /Applications/PHPStorm'' - though I'm not sure if that IDE uses Workspaces in a way that he can point it at the project.. For dev/testing, running on a port above 1024 would seem like a bit less effort than an nginx reverse proxy, though they are fairly easy to establish. Commented Jan 29, 2014 at 20:16
  • If OSX's Apache is running on port 80 and I cannot use it from my IDE, is there any point in it running? Would it make sense to turn it off? Is that possible?
    – Justin
    Commented Jan 29, 2014 at 20:21
  • @Justin Unless you have something that is specifically required to be port 80 even in development, I would just use port 8080. It creates the least amount of headaches/work and security holes. Commented Jan 29, 2014 at 22:41
  • Thanks. While I was able to get Apache stopped so localhost address was freed up (no more "It works!" page), I still could not run my IDE on port 80 for the reason you describe in your answer. I'll just deal with the ugly URL for dev.
    – Justin
    Commented Jan 30, 2014 at 18:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .