Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

greenmac

macrumors regular
Original poster
Aug 11, 2006
135
0
Adelaide
I just want to change from port 80 to anything for eg. 8080.
How do I do that.
Oh and I found if I do a search on terminal for httpd.conf on this computer(Mac Pro) I get this
josh-greens-computer:~ greenjo$ locate httpd.conf
locate: no database file /var/db/locate.database.

however on another computer i have (eMac) I get this
Joshua-Greens-Computer:~ joshuagreen$ locate httpd.conf
/private/etc/httpd/httpd.conf
/private/etc/httpd/httpd.conf.applesaved
/private/etc/httpd/httpd.conf.bak
/private/etc/httpd/httpd.conf.default

I don't know wheather this means much.
Thanks for any help I receive.
 
not sure if the Intel builds are different, but on my PPC the built-in Apache that come with OSX has its conf files at /etc/httpd

the etc folder is hidden so you need to use Finder > Go menu > Go to Folder > /etc/httpd

to open the ports you need to set Apache to Listen on whichever ones you want open (with multiple specific Listen directives)

Then use the Virtual Host containers to specify which ports go where when attached to a particular request - eg
Listen 80
Listen 8080
Listen 443
....
NameVirtualHost *:443
<VirtualHost *:443>
ServerName www.whatever.co.nz
...
<Directory "/Library/WebServer/Documents/zeroadmin">
...
</Directory>
</VirtualHost>

NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.whatever.co.nz
...
<Directory "/Library/WebServer/Documents/zero">
...
</Directory>
</VirtualHost>

NameVirtualHost *:8080
<VirtualHost *:8080>
ServerName www.whatever.co.nz
...
<Directory "/Library/WebServer/Documents/zero2">
...
</Directory>
</VirtualHost>

So that http://www.whatever.co.nz goes to the default site but https://www.whatever.co.nz goes to the admin version
and http://www.whatever.co.nz:8080 goes somewhere else again.
there are i believe many ways to do this, and the ServerNames can be all different if you like, or use different sub-domains (like admin.whatever.co.nz), but i personally find this the cleanest and clearest.

Using *.[port] means that you have to order the Virtual Hosts correctly - Apache goes through them in order and the first match it finds, that's where the request goes, if there's no match it send it to the first one (with the right port). Which can handy if you have a lot of different domains but want most of them to point to a "default" site without having to set up Virtual Host containers for all of them.

Is that too much information? On the wrong subject? :D
 
thanks, I've found the file, Its where you said, but all I want to do is change the port used to something else, I want to test because I think my isp might be blocking port 80, I rang and asked, response:"I can't tell you" gee thanks.
I'm not sure where your heading with virtual hosts, I dont think thats what I need.
So main question is how do I change it to a different port, step by step, I'm new to this. I need it spelled out like what do I use to open httpd.conf what lines need changing.
 
ah ok. Firstly, i don't think your ISP would be blocking 80. It's possible, but i can't imagine why it would be worth the hassle. So, first thing is to check whether it's really blocked

open Applications > Utilities > Network Utility : Port Scan tab

Ip address: [enter the ip address that's showing in System Preferences > Network : Status - Built In Ethernet]

check "Only scan between" 80 and 80

If it comes back open, that's good.

How do you connect to the internet, via a router or directly to the ISP via a modem?

Do you have a static IP address?

It might help also to have an idea of why you want 80 open - are you planning on hosting a site?

The more info you can supply, the easier it is to know where to look fro the problem.
Cos, the next thing is to test is whether your router is blocking 80 (quite possible, likely even, if you haven't told it otherwise)
 
greenmac said:
thanks, I've found the file, Its where you said, but all I want to do is change the port used to something else, I want to test because I think my isp might be blocking port 80, I rang and asked, response:"I can't tell you" gee thanks.
I'm not sure where your heading with virtual hosts, I dont think thats what I need.
So main question is how do I change it to a different port, step by step, I'm new to this. I need it spelled out like what do I use to open httpd.conf what lines need changing.

Hi, greenmac. Exit TextEdit if it is current open and then start Terminal (in Applications/Utilities) and enter the following command:
sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/httpd/httpd.conf
Now search for the line that says 'Port 80'. Change this to 'Port 8080' or whatever port you want, save the file and then restart the server.

If you ISP is blocking the port, it is happening at a router further up than your computer. Locally port scanning your own computer will not reveal this block (which they do specifically to prevent people from running servers -- ISPs like that are ruining the internet ;) ). Instead, try to access it from outside your ISP like with this site: http://www.radiotoolbox.com/online_tools/cantheygetin.php
 
Kunimodi said:
Hi, greenmac. Exit TextEdit if it is current open and then start Terminal (in Applications/Utilities) and enter the following command:
sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/httpd/httpd.conf
Now search for the line that says 'Port 80'. Change this to 'Port 8080' or whatever port you want, save the file and then restart the server.

If you ISP is blocking the port, it is happening at a router further up than your computer. Locally port scanning your own computer will not reveal this block (which they do specifically to prevent people from running servers -- ISPs like that are ruining the internet ;) ). Instead, try to access it from outside your ISP like with this site: http://www.radiotoolbox.com/online_tools/cantheygetin.php

If your running the latest version of stuff (intel) then Port is replaced with Listen. Port doesn't work anymore. At least this is what I have found.
 
fall3n said:
If your running the latest version of stuff (intel) then Port is replaced with Listen. Port doesn't work anymore. At least this is what I have found.

Ah, did Apple finally upgrade to Apache 2.x? :) Port is an Apache 1.x directive, but is how it is implemented in the default Apache installations I've seen (though Listen is still present, it's used for matching to an IP), including OS X Server. This is how it is on my Mac Pro. However, MAMP (for example) currently uses Apache 2.0. Are you sure you're using a stock httpd?
 
greenmac said:
my isp might be blocking port 80
you could be right. my bell isp blocks all known-ports below 1024.

things to check:
- your httpd.conf Listen directive is set to 8080 (as others have suggested)
- your firewall config is open for 8080 (create a new one, if you haven't)
- your router (if you have one), is configure to forward requests on port 8080 to port 8080 ...

alternatively, if you have a router, you can make port 8080 to point to the local port 80. then, you don't have to change the apache config.
 
Im getting there i think

I ve found the line PORT so I can change that, this is what the line listen says
#Listen 3000
#Listen 12.34.56.78:80
does that stay like that or change?
 
I have a router I put port forwarding on on port 80, and 8080, and set a new firewall rule for 8080, as of when I first started this, first things I did I think, not sure how to redirect with my router, I've seen my mates and his Dlink is a better set up over my Billion, He has no trouble hosting his site from his house on dynamic ip, but he had a look at mine and we think its port 80 blocked from isp, I asked them and response was they wouldnt tell me.
 
greenmac said:
I ve found the line PORT so I can change that, this is what the line listen says
#Listen 3000
#Listen 12.34.56.78:80
does that stay like that or change?

That's fine; those are examples. Anything after a # character is treated as a comment.
 
greenmac said:
I ve found the line PORT so I can change that, this is what the line listen says
#Listen 3000
#Listen 12.34.56.78:80
does that stay like that or change?

what you want to do is just, enter another line that would have the new entry. in the end the section should look like:

#Listen 3000
#Listen 12.34.56.78:80
Listen 8080


the directive with the ip is useful if you have multiple interface and you want to bind the port to a specific ip. in your case, you don't need it.

after you change the config, you caan run

apachectl restart

Then go to your browser and type:
http://localhost:8080

you should get your homepage (or the apache start page) if you have it configured properly.

to make sure it works outside the firewall in your local machine, go to another pc ad try to access the page from there:

http://yourip:8080

hope this helps. have fun!
 
it's interesting that your domain resolves to a private network's ip:

Non-authoritative answer:
Name: shaggygreeneye.boldlygoingnowhere.org
Address: 10.0.1.4

Hence, I will not be able to check it and I don't think anyone else can. I maybe wrong.

And, unfortunately, you have to put the port number :(
 
greenmac said:
Ive changed the port and http://www.radiotoolbox.com/online_t...ntheygetin.php says a server is runninig on it, so now I just need someone to verify
http://shaggygreeneye.boldlygoingnowhere.org:8080/ this will show the apache server.
anyone know a way of changing my adress so you dont need to put :8080 on end?

If you go to http://whatsmyip.com and post the IP, we can try to access it using that. You'll want to configure your name server to resolve shaggygreeneye.boldygoingnowhere.org to that IP.
 
I think it must be the billion router then thats not forwarding the ports like it should be, I think I'll give it the flick, and try and use Airport as router, means I have to buy a new modem though, If thats the case I can use port 80, well atleast I've learned aliitle along the wy, Thanks guys
 
greenmac said:
I think it must be the billion router then thats not forwarding the ports like it should be, I think I'll give it the flick, and try and use Airport as router, means I have to buy a new modem though, If thats the case I can use port 80, well atleast I've learned aliitle along the wy, Thanks guys

Yep, I'm sorry, but the IP does not seem to be accessible Good luck with the different router -- maybe a hosted account would be worth getting.
 
Kunimodi said:
Ah, did Apple finally upgrade to Apache 2.x? :) Port is an Apache 1.x directive, but is how it is implemented in the default Apache installations I've seen (though Listen is still present, it's used for matching to an IP), including OS X Server. This is how it is on my Mac Pro. However, MAMP (for example) currently uses Apache 2.0. Are you sure you're using a stock httpd?

Nope, Apple didn't upgrade yet, but I think it's part of PHP 5 as I'm still using Apache 1.3 (cause there are to many problems with my intel c2d, as far as i know) but am using php 5 and mysql 5. Though i havn't tried the port setting with my apache 1.3 because listen worked just fine with my setup.
 
fall3n said:
Nope, Apple didn't upgrade yet, but I think it's part of PHP 5 as I'm still using Apache 1.3 (cause there are to many problems with my intel c2d, as far as i know) but am using php 5 and mysql 5. Though i havn't tried the port setting with my apache 1.3 because listen worked just fine with my setup.

Are you using MAMP or another stack? PHP doesn't include Apache and neither does MySQL (though the stock OS X includes PHP (4 I think) if you enable it and OS X server has MySQL). You can build Apache 2.2 from sources of Mac (including Intels) and it works well, though I've had problems with svn dav integration before. Of course <religiouswar>mod_python and PostgreSQL are much better</religiouswar>! :D
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.