Skip to content

Instantly share code, notes, and snippets.

@mcortes19
Last active May 16, 2017 21:02
Show Gist options
  • Save mcortes19/f50c5c1fa46dc56b187fd1b1fbb3b021 to your computer and use it in GitHub Desktop.
Save mcortes19/f50c5c1fa46dc56b187fd1b1fbb3b021 to your computer and use it in GitHub Desktop.
Tools to improve the local development on Mac

Mac OS X Setup Guide

Mac OS tool image

COMMAND LINE DEVELOPER TOOLS

  • Install Xcode

      xcode-select --install
    
  • Install Homebrew

      ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    

More commands and settings [[HOMEBREW SETTINGS]]

  • Install Homebrew Cask

      brew tap caskroom/cask
    

More commands and settings [[HOMEBREW SETTINGS]]

  • Install and Configure GIT

      brew install git
      git config --global user.name "NAME"
      git config --global user.email "correo@electronico"
      git config --global credential.helper 'cache --timeout=3600'
    
  • More commands

  • Install Sublime-Text

      brew cask install sublime-text
    
  • Package Control

      import urllib.request,os,hashlib; h = 'df21e130d211cfc94d9b0905775a7c0f' + '1e3d39e33b79698005270310898eea76'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by) 
    
  • Packages

    • ApplySyntax
    • BracketHighlighter
    • Color Highlighter
    • CSS Snippets
    • Drupal
    • Emmet
    • GitGutter
    • Markdown Preview
    • MarkdownHighlighting
    • Material Theme
    • Material - Appear
    • Sass
    • SideBarEnhancements
    • Terminal
  • User setting

    {
        "always_show_minimap_viewport": true,
        "bold_folder_labels": true,
        "caret_style": "phase",
        "color_scheme": "Packages/Material Theme/schemes/Material-Theme.tmTheme",
        "copy_with_empty_selection": false,
        "default_encoding": "UTF-8",
        "default_line_ending": "unix",
        "draw_white_space": "all",
        "enabled_parsers":
        [
            "markdown",
            "github",
            "multimarkdown"
        ],
        "ensure_newline_at_eof_on_save": true,
        "fade_fold_buttons": false,
        "fallback_encoding": "UTF-8",
        "find_selected_text": true,
        "font_options":
        [
            "gray_antialias"
        ],
        "font_size": 18,
        "highlight_line": true,
        "highlight_modified_tabs": true,
        "ignored_packages":
        [
            "Vintage"
        ],
        "indent_guide_options":
        [
            "draw_normal",
            "draw_active"
        ],
        "line_padding_bottom": 3,
        "line_padding_top": 3,
        "markdown_binary_map":
        {
            "multimarkdown":
            [
                "/usr/local/bin/multimarkdown"
            ]
        },
        "material_theme_accent_pink": true,
        "material_theme_accent_scrollbars": true,
        "material_theme_big_fileicons": true,
        "material_theme_bold_tab": true,
        "material_theme_bright_scrollbars": true,
        "material_theme_bullet_tree_indicator": true,
        "material_theme_compact_panel": true,
        "material_theme_compact_sidebar": true,
        "material_theme_contrast_fileicon": true,
        "material_theme_contrast_mode": true,
        "material_theme_panel_separator": true,
        "material_theme_small_statusbar": true,
        "material_theme_small_tab": true,
        "material_theme_tabs_autowidth": true,
        "material_theme_tabs_separator": true,
        "material_theme_tree_headings": true,
        "open_files_in_new_window": false,
        "overlay_scroll_bars": "enabled",
        "rulers":
        [
            50
        ],
        "shift_tab_unindent": true,
        "show_encoding": true,
        "tab_size": 2,
        "tabs_small": true,
        "terminal": "iTerm2-v3.sh",
        "theme": "Material-Theme.sublime-theme",
        "translate_tabs_to_spaces": true,
        "trim_automatic_white_space": true,
        "trim_trailing_white_space_on_save": true,
        "use_tab_stops": true,
        "word_wrap": true
    }    
  • Install Extra brew taps

      brew tap homebrew/dupes
      brew tap homebrew/versions
      brew tap homebrew/php
      brew tap homebrew/apache
    
  • Stop default Mac Apache server service

      sudo apachectl stop
    
  • Unload default Mac Apache Server service

      sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
    
  • Install brew Apache

      brew install httpd24 --with-privileged-ports --with-http2
    
  • Mount the new Apache service

      sudo cp -v /usr/local/Cellar/httpd24/2.4.25/homebrew.mxcl.httpd24.plist /Library/LaunchDaemons
      sudo chown -v root:wheel /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist
      sudo chmod -v 644 /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist
      sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.httpd24.plist
    
  • Restart Apache

      sudo apachectl -k restart
    
  • Other Apache commands

      sudo apachectl start
      sudo apachectl stop
      sudo apachectl -k restart
    
  • Apache Settings

      subl /usr/local/etc/apache2/2.4/httpd.conf
    
  • Set the listening port number

      Listen 80
    
  • Assing your user to Apache

      User your_user
      Group staff
    
  • Uncomment

      LoadModule rewrite_module libexec/mod_rewrite.so
    
  • Change the DocumentRoot

      DocumentRoot “”/Users/your_user/Sites””
          <Directory “”/Users/your_user/Sites””>
    
      # AllowOverride controls what directives may be placed in .htaccess files.
      # It can be "All", "None", or any combination of the keywords:
      #   AllowOverride FileInfo AuthConfig Limit
      #
      AllowOverride All
    
  • Create a Sites folder

      mkdir ~/Sites
      echo "<h1>My User Web Root</h1>" > ~/Sites/index.html
    
  • Restart Apache

      sudo apachectl -k restart
    

[Reference]

  • Install PHP 70

      brew install php70 --with-httpd24
    
  • Settings

      subl /usr/local/etc/php/7.0/php.ini
    
      upload_max_filesize = 256M
      post_max_size = 512M
      memory_limit = 1024M
      max_execution_time = 120
      date.timezone = "America/Costa_Rica"
    
  • Update the php70 module

      subl /usr/local/etc/apache2/2.4/httpd.conf
    
      LoadModule php7_module    /usr/local/opt/php71/libexec/apache2/libphp7.so
    
  • Update the Directory Index

      <IfModule dir_module>
          DirectoryIndex index.php index.html
      </IfModule>
    
      <FilesMatch \.php$>
          SetHandler application/x-httpd-php
      </FilesMatch>
    
  • Restart Apache

      sudo apachectl -k restart
    
  • Create a php test file

      echo "<?php phpinfo();" > ~/Sites/info.php
    

MYSQL

  • Install mysql

      brew install mysql
    
  • Install brew services

      brew tap homebrew/services
    
  • Load and start the MySQL service

      brew services start mysql
    

This instruction is equal to type:

ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

  • Check of the MySQL service has been loaded

      brew services list
    
  • To set the root password

      mysqladmin -u root password 'yourpassword'
    

Important : Use the single ‘quotes’ to surround the password and make sure to select a strong password!

  • Create my.cnf file*

      subl  ~/my.cnf
    
  • Fill it with:

      [mysqld]
      max_allowed_packet=128M
      wait_timeout=300
      sql_mode=NO_ENGINE_SUBSTITUTION
    

###References

  1. Alphanso Tech
  2. Coolest guides on the planet
  3. macOS 10.12 Sierra Apache Setup: Multiple PHP Versions
  4. Using different PHP versions on OSX with Apache and Homebrew

PHPMYADMIN

brew install josegonzalez/php/phpmyadmin

Add (to the end) of the Apache configuration

subl /etc/apache2/httpd.conf

PHPMYADMIN

Alias /phpmyadmin /usr/local/share/phpmyadmin
<Directory /usr/local/share/phpmyadmin/>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Require all granted
</Directory>

Restart Apache

sudo apachectl restart
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/php

brew install drush

COMPOSER

brew install composer
brew install terminus

Usage 1

Usage 2

  • Install Node

      brew install node
    
  • GULP

      npm install --global gulp
    
  • BOWER

      npm install --global bower
    

Important : If we find some problems in the folder /usr/local

    sudo chown -R $USER /usr/local

TERMINAL SETTINGS

###ZSH SHELL

  • Install zsh shell

      brew install zsh
    
  • Set zsh to default shell

      chsh -s /usr/local/bin/zsh
    
  • Confirm you're runnig zsh

      echo $SHELL
    

###iTerm2 + oh my zsh + solarized + Meslo powerline font (OSX / macOS)

  • Install iTerm2

      brew cask install iterm2
    
  • Install font packages

      brew tap caskroom/fonts
      
      brew cask install font-meslo-for-powerline
    
  • Install Oh My Zsh

      sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
    

Info : oh-my-zsh Cheatsheet

  • Install Autosuggestions

      git clone https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
    
  • Add the plugin to the list of plugins for Oh My Zsh to load in ~/.zshrc

      plugins=( [plugins...] zsh-autosuggestions)
    
  • Install Syntax highlighting

       git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
    
  • Add the plugin to the list of plugins for Oh My Zsh to load in ~/.zshrc

      plugins=( [plugins...] zsh-syntax-highlighting)
    
  • Install Completions

      git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-completions
    
  • Add the plugin to the list of plugins for Oh My Zsh to load in ~/.zshrc

      plugins=( [plugins...] zsh-completions)
    

###Hyper Terminal

DOC REFERENCES

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment