Change webserver port in OS X
A while ago with the Code Red virus making an ass of Microsoft and its users, many cable internet providers (including mine) started blocking port 80, the default port that web pages are served on. Now I’m using DSL and serving on port 80 again, but to work around ISP blocking of port 80 I had to change which port Apache used to serve the site. Once you do this you also need to change the address you type into your browser to get to your site. For instance if you were serving at an address such as (in my case) aliandcedar.com now you need to type in aliandcedar.com:400, where “400″ is the new port number I chose to serve from. Keep in mind that you don’t need your own domain name. You could just use your IP address rather than a domain name.
- Figure out how to open text files as root.
- navigate to or find
/private/etc/httpd/ - From that directory make a backup copy of “httpd.conf” put it somewhere safe
- Open “httpd.conf” as root.
- Look around! This is an interesting file that controls how your apache works. You can learn a lot just by looking.
- find this line of text:
Port 80 - Now change this to read:
Port newnumberwhere “newnumber” is the new port number you have chosen. You need to choose a number that is will not be used by another application or process. I chose 400, though I had no good reason for doing so. Folks with more knowledge than me may understand the rational for choosing certain port numbers. - Save your changes
- Stop and Start “Personal Web Sharing” from the Preferences Panel
- Good luck!
May 8th, 2006 at 8:46 am
testing too