Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > how do i run apache on 2 ports?

how do i run apache on 2 ports?
Thread Tools
Mac Elite
Join Date: Sep 2000
Location: New York
Status: Offline
Reply With Quote
Jun 12, 2003, 11:33 PM
 
It appears that my cable modem provider has blocked web serving for users because I can't access my computer remotely over http, but ftp and ssh work fine. So I would like to run apache on another port, however I also want to keep it on port 80 because I do a lot of testing on my internal network and directly on this Mac and it would be annoying to have to type in the port all the time when testing.

Can this be done with ipfw? As far as I know, apache only serves on one port at a time.
     
Senior User
Join Date: Sep 2000
Location: Shallow Alto, CA
Status: Offline
Reply With Quote
Jun 13, 2003, 12:14 AM
 
You just need to add a virtual host directive for the port you want to host on. First, tell apache to listen to the port. Open /etc/httpd/httpd.conf and find
Listen 80
then add the port you want to listen on. I.e.

Listen 8080

Next, look for VirtualHost (near the end of the file) and add

Code:
<VirtualHost 127.0.0.1:8080> ServerName localhost DocumentRoot "/path/to/your/webserver/files" </VirtualHost>
Code:
<VirtualHost your.ip.address.here:8080> ServerName localhost DocumentRoot "/path/to/your/webserver/files" </VirtualHost>
You and others should now be able to access the site via port 8080
http://my.ip.address:8080/
You will still be able to access the site from within on port 80 via http://localhost/ or http://127.0.0.1/

VirtualHost is a great way to do development on multiple sites at the same time. I work on a number of sites and just server them on different ports and give them different DocumentRoot locations. You can also change your DocumentRoot if you don't like the default location...I set mine up to exactly mirror my ISPs so that if I need to hard code any paths, they won't need to be switched when I upload to the ISP. Hope that helps.
     
Mac Elite
Join Date: Sep 2000
Location: New York
Status: Offline
Reply With Quote
Jun 13, 2003, 01:53 AM
 
so I need to add both blocks of code? and I keep those localhost IPs? and there is no "Listen 80" but there's "Port 80" so I assume you mean that. I'm afraid to screw up my apache conf file because I've killed apache in the past by doing something that I didn't completely understand.
     
Xeo
Moderator Emeritus
Join Date: Mar 2001
Location: Austin, MN, USA
Status: Offline
Reply With Quote
Jun 13, 2003, 07:51 AM
 
Originally posted by waffffffle:
I'm afraid to screw up my apache conf file because I've killed apache in the past by doing something that I didn't completely understand.
Start out by backing it up. If you screw it up, you can revert. Just keep the backup around and you have nothing to worry about.
     
Senior User
Join Date: Jun 2001
Location: Merry Land
Status: Offline
Reply With Quote
Jun 13, 2003, 08:04 AM
 
Originally posted by Xeo:
Start out by backing it up. If you screw it up, you can revert. Just keep the backup around and you have nothing to worry about.


Backups are a good thing
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:33 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2