How to create virtual hosts in MAMP?

后端 未结 6 1136
我寻月下人不归
我寻月下人不归 2020-12-05 00:35

I am new to Mac but used Ubuntu for development for a long time. I know how to create virtual hosts in Ubuntu but have no idea about Mac. I have created a hosts

6条回答
  •  失恋的感觉
    2020-12-05 01:07

    1. Allow virtual hosts

      Go to Applications > MAMP > conf > apache > httpd.conf

      Find this line:

      # Virtual hosts
      #Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
      

      Uncomment the code by removing the hash symbol.

      # Virtual hosts
      Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
      
    2. Allow SymLink Override

      Find this line in that same httpd.conf file.

      
          Options Indexes FollowSymLinks
          AllowOverride None
      
      

      change None to All.

      
          Options Indexes FollowSymLinks
          AllowOverride All
      
      
    3. Add the virtual host path

      Go to Applications > MAMP > conf > apache > extra > httpd-vhosts.conf

      add the virtual host with servname and document root like the below code

      
        ServerName example.dev
        DocumentRoot "/path/to/directory"
      
      
    4. Allow your computer to recognize your local domain

      Open terminal and type

      sudo pico /etc/hosts
      

      then add your domain

      127.0.0.1 example.dev
      
    5. Restart your server.

      If the url is showing error in chrome try safari

提交回复
热议问题