 |
 |
how do i run apache on 2 ports?
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: New York
Status:
Offline
|
|
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
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
|
 |
|
Moderator Emeritus 
Join Date: Mar 2001
Location: Austin, MN, USA
Status:
Offline
|
|
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
|
|
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 
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |