How to Set-Up A Multiple IP Based Apache Virtual-Hosts Loopback for Localhost on Mac OS X

May 13, 2013 | By Duchateaux.

The Easy Guide shows you Step-by-Step How to Set-Up an IP Based Virtual Hosts Loopback for Apache Web Server on macOS Desktop.

The Contents and Details are Essentials and Give Focus only to Instructions and Commands.

Apple on Cloud
  1. Open Terminal Window
    (Press “Enter” to Execute Commands)

  2. Make a Loopback Alias

    sudo su

    If Got “User is Not in Sudoers file” then see: How to Enable sudo
    Example:

    ifconfig lo0 alias 127.0.0.2

  3. Inserts New IP on /etc/hosts

    nano /etc/hosts

    Modify Line Containing localhost for Example Like:

    127.0.0.1, 127.0.0.2 localhost

    Ctrl+x to Save & Exit :)

  4. Enabling Virtual Host

    1. Enable Virtual-Host Conf File
      nano /conf/httpd.conf

      Check that the Line Below Is Not Commented Out…

      Include /extra/httpd-vhosts.conf

      (By Default apache2 Dir is Inside /private/etc/)

    2. Make the New Host Directory
      mkdir /Library/WebServer/Documents2
      echo 'Working!' > /Library/WebServer/Documents2/index.html
    3. Set-Up IP Based Virtual-Hosts
      nano /extra/httpd-vhosts.conf

      Inserts Something Like:


      ServerAdmin admin1@example.com
      DocumentRoot “/Library/WebServer/Documents”
      ServerName localhost.1
      ErrorLog “/private/var/log/apache2/localhost1.com-error_log”


      ServerAdmin admin2@example.com
      DocumentRoot “/Library/WebServer/Documents2”
      ServerName localhost.2
      ErrorLog “/private/var/log/apache2/localhost2.com-error_log”

    4. Give Permissions to New Host Root Directory
      nano /conf/httpd.conf

      Inserts Below the Existing Root Directory:


      Options Indexes FollowSymLinks MultiViews
      AllowOverride None
      Order allow,deny
      Allow from all

  5. Restart Apache

  6. Next Access New Virtual Host on Browser
    It Should Be Just Successfully Working! :)

  7. How to Install Apache Cassandra NoSQL Database for macOS:

    Cassandra Installation Mac

QuickChic Theme • Powered by WordPress