Git Product home page Git Product logo

dymond / vhosts-mamp-proxy-setup Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 13 KB

This project is so that I can remember how I set up my local dev environment in case of a catastrophic failure / me being a complete idiot who forgets everything (which is absolutely certain to happen). It details how to set up MAMP to display your site at a custom URL of your choosing for multiple projects with vhosts.

License: The Unlicense

ApacheConf 100.00%

vhosts-mamp-proxy-setup's Introduction

Creating Custom URLs for local development with MAMP vhosts

  1. Set Web & MySQL ports to 80 & 3306 in MAMP preferences
  2. Open /Applications/MAMP/conf/apache/httpd.conf and search for -vhosts.conf. If you have the default httpd.conf, only one match will show up on line 585 and you'll need to uncomment that line by deleting the # at the start of it.
    • It will go from this: # Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
    • to this: Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
  3. Copy the httpd-vhosts.conf file from this repo into /Applications/MAMP/conf/apache/extra
  4. Edit httpd-vhosts.conf to reflect the correct location of your site directory on your local drive and the new site URL you want
    • Lines 34, 35 and 36 should each be edited
    • If you want to work on multiple sites, duplicate the entire section below and change those three parameters for each site.
<VirtualHost *:80>
    DocumentRoot "/Users/*NAME*/dev/site"     <-- Put your local directory here
    ServerName site.url                       <-- Put your desired url here
    <Directory "/Users/*NAME*/dev/site">      <-- Put your local directory here
        Options Indexes FollowSymLinks
        AllowOverride All
    </Directory>
</VirtualHost>
  1. Edit hosts file and add this line:
    • 127.0.0.1 localhost yoursite.url
    • If you are working on multiple sites, create an entry for each site url.
      • (Hostbuddy allows quick, easy swapping of hosts files)
  2. Restart the MAMP servers

Additional step for browser-sync users

You can get browser-sync to work by adding proxy: "yoursite.url" to your browser-sync options. Depending on your task runner environment, this can be different. These examples are for gulp and grunt. I don't use brunch, but it should be fairly simple to figure out.

Gulp users

Add this to your gulpfile:

var browserSyncOptions = {
	proxy: "yoursite.url"
};

Be careful! I would recommend searching for browserSyncOptions in your gulpfile if you didn't hand build it. If it's already set, just add proxy: "yoursite.url", in with the other options.

Grunt users

You should reference the docs. As long as your setup isn't really funky, it should be pretty straightforward to just add the proxy line to your task so that it looks something like this:

browserSync: {
	dev: {
		bsFiles: {
			src : 'assets/css/style.css'
		},
		options: {
			proxy: "local.dev"
		}
	}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.