Can AMPPS run a virtual host with different ports on the same IP?

0

I want to have two different directories, opened from the same IP, but different ports. I can't find a way to do this, I have tried many different forums, and Google, but still found nothing. Can I create a Virtual Host like that?

Example:

127.0.0.1:80 -> /Applications/AMPPS/www80

127.0.0.1:12 -> /Applications/AMPPS/www12

Yes, I am running on Mac, but the instructions should be the same between Mac and Windows

Jaketr00

Posted 2016-09-20T02:25:33.520

Reputation: 279

Answers

1

Yes that is possible by configuring 2 virtual hosts. You'll need to ensure that Apache is also configured to listen on both ports by modifying httpd.conf and adding the following line.
Listen 12

You could configure apache similar to the following configuration.

<VirtualHost *:80>
    DocumentRoot "/Applications/AMPPS/www80"
</VirtualHost>

<VirtualHost *:12>
    DocumentRoot "/Applications/AMPPS/www12"
</VirtualHost>

You would place that configuration in the sites-available configuration directory, then use a2ensite to actually enable the site and then restart apache.

Reference:
https://httpd.apache.org/docs/2.4/vhosts/

https://httpd.apache.org/docs/2.4/vhosts/ip-based.html

Lawrence

Posted 2016-09-20T02:25:33.520

Reputation: 3 807

probably a dumb question, but where is the sites-available configuration directory? – Jaketr00 – 2016-09-20T02:48:09.017

@Jaketr00 Looks like it may be in /etc/apache2/extra/ and might be called httpd-vhosts.conf - according to this link - https://coolestguidesontheplanet.com/set-virtual-hosts-apache-mac-osx-10-10-yosemite/

– Lawrence – 2016-09-20T02:52:17.960

I'm still getting an error, "127.0.0.1 didn’t send any data." I tried both httpd.conf and extra/httpd-vhosts.conf – Jaketr00 – 2016-09-20T02:56:35.413

@Jaketr00 Do the apache logs show any attempts or errors when you try and access it? – Lawrence – 2016-09-20T02:58:25.980

both the access logs and error logs show nothing, they are both blank – Jaketr00 – 2016-09-20T03:00:40.973

Does it work with only one VirtualHost configured? – Lawrence – 2016-09-20T03:07:48.340

the original port, 80, still works no matter what, but the second port, 12, doesnt ever work – Jaketr00 – 2016-09-20T03:08:47.703

Ah, I had assumed you had configured Apache to listen on port 12 already. You may need to configure that as well - https://httpd.apache.org/docs/2.4/bind.html

– Lawrence – 2016-09-20T03:09:41.413

that would have been my issue, i had assumed that the listen worked with commas, so i wrote Listen 80,12, thank you – Jaketr00 – 2016-09-20T03:19:29.363