Create VirtualHost in your MAMP.

Creating virtualhost on MAMP is very easy. Suppose you want to make a virtualhost named

1
local.myweb.com

. Just follow the steps below…

  1. Open your hosts file located in
    1
    /etc/hosts

    . To open a file either you can use your favorite text editor or use nano in command line.

    1
    sudo nano /etc/hosts

    . Now add the following line

    1
    127.0.0.1 local.myweb.com

    (Save and exit. If you are using nano then press ctrl+x, press y then press enter).

  2. Create a file named
    1
    vhosts.conf

    in

    1
    /Applications/MAMP/conf/apache/vhosts.conf

    and then open it.

  3. Copy and paste following lines in it.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <VirtualHost *:80>
      ServerName local.myweb.com
      ServerAlias local.myweb.com
      DocumentRoot /Applications/MAMP/htdocs/myweb
      ErrorLog /Applications/MAMP/logs/myweb.log.txt
      DirectoryIndex index.html index.htm index.php index.php4 index.php5
      <Directory /Applications/MAMP/htdocs/myweb/>
        Options -Indexes +IncludesNOEXEC +FollowSymLinks
        allow from all
        AllowOverride All
      </Directory>
    </VirtualHost>
  4. Enable your virtualhost by adding below line in
    1
    /Applications/MAMP/conf/apache/httpd.conf

    at the bottom of the file.

    1
    2
    NameVirtualHost *:80
    Include /Applications/MAMP/conf/apache/vhosts.conf
  5. Restart your apache server and test it. Open your web browser and type local.myweb.com you will see

Tada you are done! Enjoy and correct me if I’m wrong :)

Related posts:

  1. How to change root password on MAMP
  2. Creating virtual host in ubuntu.
  3. Get started with Zend Framework.

2 Responses to “Create VirtualHost in your MAMP.”

  1. Nice blog, keep it up :)

Trackbacks/Pingbacks

  1. Get started with Zend Framework. | My Planet - [...] root by creating a virtual host. If you don’t know how to create it please follow this post. 1234567891011<VirtualHost ...

Leave a Reply