Skip to content

Instantly share code, notes, and snippets.

@dommmel
Forked from jonathanstark/mamp_function
Last active March 24, 2018 20:10
Show Gist options
  • Save dommmel/bb9b13c9222b0fdd9f32399fd3b1580d to your computer and use it in GitHub Desktop.
Save dommmel/bb9b13c9222b0fdd9f32399fd3b1580d to your computer and use it in GitHub Desktop.

Revisions

  1. dommmel revised this gist Mar 24, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mamp_function
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ function mamp() {
    CONF_FILE="/Applications/MAMP/conf/apache/httpd.conf"
    #
    # Fish existing doc root out of conf file
    LINE=$(cat $CONF_FILE | grep ^DocumentRoot)
    LINE=$(cat $CONF_FILE | grep "^DocumentRoot")
    QUOTED_STRING=${LINE/DocumentRoot /}
    OLD_DOC_ROOT=${QUOTED_STRING//\"/}
    #
  2. @jonathanstark jonathanstark revised this gist Jan 23, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion mamp_function
    Original file line number Diff line number Diff line change
    @@ -15,5 +15,5 @@ function mamp() {
    sed -i.bak -e "s|${OLD_DOC_ROOT}|${NEW_DOC_ROOT}|g" $CONF_FILE
    #
    # Restart server
    sudo /Applications/MAMP/Library/bin/apachectl -k restart && sleep 2 && open "http://localhost/"
    sudo /Applications/MAMP/Library/bin/apachectl -k restart && sleep 2 && open "http://localhost:8888/"
    }
  3. @jonathanstark jonathanstark created this gist Jan 23, 2014.
    19 changes: 19 additions & 0 deletions mamp_function
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    function mamp() {
    #
    # Default location of the apache conf file for MAMP
    CONF_FILE="/Applications/MAMP/conf/apache/httpd.conf"
    #
    # Fish existing doc root out of conf file
    LINE=$(cat $CONF_FILE | grep ^DocumentRoot)
    QUOTED_STRING=${LINE/DocumentRoot /}
    OLD_DOC_ROOT=${QUOTED_STRING//\"/}
    #
    # Set new doc root to current directory
    NEW_DOC_ROOT=$(pwd)
    #
    # Replace doc root strings in conf file
    sed -i.bak -e "s|${OLD_DOC_ROOT}|${NEW_DOC_ROOT}|g" $CONF_FILE
    #
    # Restart server
    sudo /Applications/MAMP/Library/bin/apachectl -k restart && sleep 2 && open "http://localhost/"
    }