1

I am gonna start hunting for a web developer job and would like to be able to showcase all my projects if needed, however, right now I can only showcase one project at a time. I've been wondering if it's even possible to host multiple websites simultaneously using MAMP.

  • In your www folder just create other folders – Abu Nooh Nov 11 '18 at 10:30
  • @AbuNooh It is a bit more complicated than that. In addition to the folder, you also need virtual host configuration. Can you write an answer with all the steps? – Stephen Ostermiller Nov 11 '18 at 12:16
  • A server is just an operating system with software to serve web pages or other services. So...yes. – Rob Nov 11 '18 at 13:14
  • Since you are only showcasing these projects for demo purposes (and perhaps depending on complexity) then maybe all you do need is.subdirectory for each? – MrWhite Nov 11 '18 at 15:41
2

Options

Hosting multiple sites on the same port

This works using one instance of the web server, which then serves the correct site based on the Host header provided by the browser.

The config would look something like this:

Listen 80

<VirtualHost 172.20.30.40:80>
    ServerName www.example.com
    DocumentRoot "/www/domain-80"
</VirtualHost>

<VirtualHost 172.20.30.40:80>
    ServerName www.example.org
    DocumentRoot "/www/otherdomain-80"
</VirtualHost>

Hosting multiple sites

This uses the port the request comes in on to select which site to serve.

The config would look something like this:

Listen 80
Listen 8080

<VirtualHost *:80>
    DocumentRoot "/www/domain-80"
</VirtualHost>

<VirtualHost *:8080>
    DocumentRoot "/www/otherdomain-80"
</VirtualHost>

Reasons to prefer one over the other

  • If you need to use clients that do not support the Host header, then you may need to use different ports.
  • If you wish to use different servers for different sites, you may need to use different ports (or proxy through one of the servers to the other).

Sources

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.