Skip to content

Instantly share code, notes, and snippets.

@mardix
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save mardix/6706eb8a8aaaa4e3424d to your computer and use it in GitHub Desktop.

Select an option

Save mardix/6706eb8a8aaaa4e3424d to your computer and use it in GitHub Desktop.

Revisions

  1. @OzzyCzech OzzyCzech revised this gist Dec 1, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install.md
    Original file line number Diff line number Diff line change
    @@ -32,7 +32,7 @@ Check if running `open http://localhost:8080` or `open http://localhost:80`

    ### Configuration

    nginx configuration files can be found here `subl /usr/local/etc/nginx/nginx`
    nginx configuration files can be found here `subl /usr/local/etc/nginx`

    Here is my basic `nginx.conf` file (do not forgot change root path):

  2. @OzzyCzech OzzyCzech revised this gist Dec 1, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install.md
    Original file line number Diff line number Diff line change
    @@ -187,7 +187,7 @@ You can found basic php-fpm config file here `subl /usr/local/etc/php/5.5/php-fp

    PHP config files can be found here `subl /usr/local/etc/php/5.5/conf.d/`. You can change `php.ini` but its more more easly keept change is spearate file:

    subl /usr/local/etc/php/5.5/conf.d/99999-roman.ini
    subl /usr/local/etc/php/5.5/conf.d/zzzzzzzzzzzz.ini

    See my configuration:

  3. @OzzyCzech OzzyCzech revised this gist Nov 29, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions install.md
    Original file line number Diff line number Diff line change
    @@ -159,6 +159,7 @@ Launch after login
    brew install php55-xdebug
    brew install php55-memcache
    brew install php55-memcached
    brew install php55-opcache

    add launch agent for memcached

  4. @OzzyCzech OzzyCzech revised this gist Nov 28, 2013. 2 changed files with 6 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions .bash_profile
    Original file line number Diff line number Diff line change
    @@ -61,8 +61,8 @@ alias mongo-restart="mongo-stop && mongo-start"
    # mysql
    #############################################################################

    alias mysql-start="sudo launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
    alias mysql-stop="sudo launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
    alias mysql-start="sudo mysql.server start"
    alias mysql-stop="sudo mysql.server stop"
    alias mysql-restart="mysql-stop && mysql-start"

    #############################################################################
    4 changes: 4 additions & 0 deletions install.md
    Original file line number Diff line number Diff line change
    @@ -221,6 +221,10 @@ Setup to autostart after login

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

    Change rights

    sudo chown -R _mysql /usr/local/var/mysql

    ### Start & restart

    launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
  5. @OzzyCzech OzzyCzech revised this gist Nov 27, 2013. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions uninstall-ports.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    sudo port -fp uninstall installed

    sudo rm -rf \
    /opt/local \
    /Applications/DarwinPorts \
    /Applications/MacPorts \
    /Library/LaunchDaemons/org.macports.* \
    /Library/Receipts/DarwinPorts*.pkg \
    /Library/Receipts/MacPorts*.pkg \
    /Library/StartupItems/DarwinPortsStartup \
    /Library/Tcl/darwinports1.0 \
    /Library/Tcl/macports1.0 \
    ~/.macports
  6. @OzzyCzech OzzyCzech revised this gist Nov 26, 2013. 2 changed files with 5 additions and 1 deletion.
    1 change: 0 additions & 1 deletion .bash_profile
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    #############################################################################
    # current prompt
    #############################################################################
    5 changes: 5 additions & 0 deletions install.md
    Original file line number Diff line number Diff line change
    @@ -221,6 +221,11 @@ Setup to autostart after login

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

    ### Start & restart

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

    ### Confugure

    First setup new password for root
  7. @OzzyCzech OzzyCzech revised this gist Nov 26, 2013. 1 changed file with 145 additions and 0 deletions.
    145 changes: 145 additions & 0 deletions .bash_profile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,145 @@

    #############################################################################
    # current prompt
    #############################################################################
    # \d – Current date
    # \t – Current time
    # \h – Host name
    # \# – Command number
    # \u – User name
    # \W – Current working directory (ie: Desktop/)
    # \w – Current working directory, full path (ie: /Users/Admin/Desktop)
    # export PS1="\u@\h\w: "
    export PS1="\w: "

    #############################################################################
    # git autocomplet and bash prompt
    #############################################################################

    source `brew --prefix git`/etc/bash_completion.d/git-completion.bash
    source `brew --prefix git`/etc/bash_completion.d/git-prompt.sh

    # configure git and prompt

    GIT_PS1_SHOWDIRTYSTATE=1
    GIT_PS1_SHOWUNTRACKEDFILES=1
    GIT_PS1_SHOWUPSTREAM="git verbose legacy"
    export PSORIG="$PS1" # pokud chcete zachovat puvodni PS1

    PS1=$PSORIG'$(__git_ps1 "\[\033[01;31m\]%s \[\033[00m\]")'


    # If you get error like: `Dubious ownership on file...` need to change rights:
    # sudo chown root <file>
    # sudo chmod 644 <filename>


    #############################################################################
    # nginx aliases
    #############################################################################

    alias nginx-start="sudo nginx"
    alias nginx-restart="sudo nginx -s reload"
    alias nginx-stop="sudo nginx -s stop"

    #############################################################################
    # php-fpm aliases
    #############################################################################

    alias php-start="sudo launchctl load ~/Library/LaunchAgents/homebrew-php.josegonzalez.php55.plist"
    alias php-stop="sudo launchctl unload ~/Library/LaunchAgents/homebrew-php.josegonzalez.php55.plist"
    alias php-restart="php-stop && php-start"

    #############################################################################
    # mongo aliases
    #############################################################################

    alias mongo-start="sudo launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist"
    alias mongo-stop="sudo launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist"
    alias mongo-restart="mongo-stop && mongo-start"

    #############################################################################
    # mysql
    #############################################################################

    alias mysql-start="sudo launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
    alias mysql-stop="sudo launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist"
    alias mysql-restart="mysql-stop && mysql-start"

    #############################################################################
    # memcached
    #############################################################################

    alias memcached-start="sudo launchctl load ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist"
    alias memcached-stop="sudo launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist"
    alias memcached-restart="memcached-stop && memcached-start"

    #############################################################################
    # aliases
    #############################################################################

    alias drives="df -h" # list all drives
    alias listen="sudo lsof -i -P | grep -i \"listen\"" # listen on ports


    alias preview="open -a '$PREVIEW'"
    alias xcode="open -a '/Developer/Applications/Xcode.app'"
    alias safari="open -a safari"
    alias firefox="open -a firefox"
    alias opera="open -a opera"
    alias chrome="open -a google\ chrome"
    alias f='open -a Finder'
    alias please=sudo

    #############################################################################
    # List aliases
    #############################################################################

    # List all files colorized in long format
    alias l="ls -l --color"

    # List all files colorized in long format, including dot files
    alias la="ls -la --color"

    # List all alias
    alias ll="ls -la" # ll alias

    # List only directories
    alias lsd='ls -l | grep "^d"'

    # list alias with -G
    alias ls="command ls -G"

    #############################################################################
    # Others
    #############################################################################

    # Enhanced WHOIS lookups
    alias whois="whois -h whois-servers.net"

    # Flush Directory Service cache
    alias flush="dscacheutil -flushcache"

    # File size
    alias fs="stat -f \"%z bytes\""

    #############################################################################
    # Prefer US English and use UTF-8
    #############################################################################

    export LC_ALL="en_US.UTF-8"
    export LANG="en_US"

    #############################################################################
    # path
    #############################################################################

    export PATH="/usr/local/Cellar/coreutils/8.21/libexec/gnubin:/usr/local/bin:/usr/local/sbin:$PATH"

    #############################################################################
    # bash history size
    #############################################################################

    export HISTCONTROL=erasedups
    export HISTSIZE=10000
    shopt -s histappend
  8. @OzzyCzech OzzyCzech created this gist Nov 26, 2013.
    310 changes: 310 additions & 0 deletions install.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,310 @@
    # Install NGINX, PHP-FPM (5.5.6), Mongo and MySql

    ## Preparation

    Download [Sublime editor](http://www.sublimetext.com/) and create link `subl`:

    sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /bin/subl

    Install [Homebrew](http://brew.sh/)

    ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"

    ## NGINX

    ### Install

    brew install nginx

    ### Running

    Follow command will autostart nginx after login

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

    You can start nginx manually and check if running in browser

    sudo nginx # start
    sudo nginx -s stop # stop
    sudo nginx -s reload # restart

    Check if running `open http://localhost:8080` or `open http://localhost:80`

    ### Configuration

    nginx configuration files can be found here `subl /usr/local/etc/nginx/nginx`

    Here is my basic `nginx.conf` file (do not forgot change root path):

    #user nobody;
    worker_processes 1;

    #error_log logs/error.log;
    #error_log logs/error.log notice;
    #error_log logs/error.log info;

    events {
    worker_connections 1024;
    }


    http {
    include mime.types;
    include sites-enabled/*.dev; # load virtuals config
    sendfile on;

    keepalive_timeout 65;

    # gzip on;
    # gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    server {
    listen 80;
    server_name localhost;

    location / {
    root /Users/roman/Sites;
    try_files $uri $uri/ /index.php?$args ;
    index index.php;
    }

    # configure *.PHP requests
    location ~ \.php$ {
    root /Users/roman/Sites;
    try_files $uri $uri/ /index.php?$args ;
    index index.html index.htm index.php;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_intercept_errors on;
    include fastcgi_params;
    }
    }
    }

    ### Setup virtuals

    First prepare follow dirs

    mkdir /usr/local/etc/nginx/sites-available
    mkdir /usr/local/etc/nginx/sites-enabled

    Create first dev configuration:

    subl /usr/local/etc/nginx/sites-available/omdesign.dev

    Here is my example configuration:

    server {
    listen *:80;
    server_name omdesign.dev;
    #access_log /Users/roman/Work/omdesign.cz/log/omdesign.dev.access.log;
    #error_log /Users/roman/Work/omdesign.cz/log/omdesign.dev.error.log;

    location / {
    root /Users/roman/Work/omdesign.cz;
    try_files $uri $uri/ /index.php?$args;
    index index.php;
    }

    location ~ \.php$ {
    root /Users/roman/Work/omdesign.cz;
    try_files $uri $uri/ /index.php?$args;
    index index.html index.htm index.php;

    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_intercept_errors on;
    include fastcgi_params;
    }

    }

    Create symlink to sites-enabled:

    sudo ln -s /usr/local/etc/nginx/sites-available/omdesign.dev /usr/local/etc/nginx/sites-nabled/omdesign.dev

    Update your `subl /etc/hosts` file with follow line:

    127.0.0.1 omdesign.dev

    Restart nginx (`sudo nginx -s reload`) and check if working (`open http://omdesign.dev`)

    ## PHP-fpm

    ### Install

    brew tap homebrew/dupes
    brew tap josegonzalez/homebrew-php
    brew install --without-apache --with-fpm --with-mysql php55

    Launch after login

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

    ### Install PHP extensions

    brew install php55-mongo
    brew install php55-xdebug
    brew install php55-memcache
    brew install php55-memcached

    add launch agent for memcached

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

    or get others

    brew search php55

    What about APC? See [stackoverflow](http://stackoverflow.com/questions/9611676/is-apc-compatible-with-php-5-4-or-php-5-5) - APC have some problems but you can install emulated APC

    brew install php55-apcu # APC

    ### Replace OS X PHP

    change `~/.bash_profile` add follow line:

    export PATH="/usr/local/bin:/usr/local/sbin:$PATH"

    Restart Terminal and check if working `php -v` or `php-fpm -v`

    ### Configuration and php.ini

    You can found basic php-fpm config file here `subl /usr/local/etc/php/5.5/php-fpm.conf`. Check especially `listen = 127.0.0.1:9000` everything else can be leave as is.

    PHP config files can be found here `subl /usr/local/etc/php/5.5/conf.d/`. You can change `php.ini` but its more more easly keept change is spearate file:

    subl /usr/local/etc/php/5.5/conf.d/99999-roman.ini

    See my configuration:

    short_open_tag = On
    display_errors = On
    display_startup_errors = On
    upload_max_filesize = 256M
    date.timezone = "Europe/Prague"
    error_reporting = E_ALL

    xdebug.idekey=PHPSTORM

    ## mongo

    brew install mongodb
    brew link mongod

    Setup to autostart after login

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

    ### Start & restart

    launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist

    ## mysql

    brew install mysql

    Setup to autostart after login

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

    ### Confugure

    First setup new password for root

    mysqladmin -u root password

    ## bash (need to be upgrade for new Git)

    brew install bash

    Open terminal cmd+, setup path to new bash `/usr/local/bin/bash`

    sudo subl /etc/shells

    add this line at the end of the list:

    /usr/local/bin/bash

    and

    chsh -s /usr/local/bin/bash YOUR_USER_NAME

    after that relaunch Terminal and check bash version

    echo $BASH_VERSION

    ## git

    brew install git
    brew unlink git && brew link git
    brew info git

    And update your `~/.bash_profile` to add autocomplete and prompt


    #############################################################################
    # My current prompt
    #############################################################################

    export PS1="\w: "

    #############################################################################
    # git autocomplet and bash prompt
    #############################################################################

    source `brew --prefix git`/etc/bash_completion.d/git-completion.bash
    source `brew --prefix git`/etc/bash_completion.d/git-prompt.sh

    # configure yout git and prompt

    GIT_PS1_SHOWDIRTYSTATE=1
    GIT_PS1_SHOWUNTRACKEDFILES=1
    GIT_PS1_SHOWUPSTREAM="git verbose legacy"

    export PSORIG="$PS1" # or remove if you don't have My custom prompt

    PS1=$PSORIG'$(__git_ps1 "\[\033[01;31m\]%s \[\033[00m\]")'

    Restart terminal (need to be quit and relaunch cmd+q)

    ## Others

    brew install npm

    Install GNU core utilities (those that come with OS X are outdated)

    brew install coreutils

    Don't forget add `/usr/local/Cellar/coreutils/8.21/libexec/gnubin` to $PATH

    Find, Locate etc. for mac

    brew install findutils

    Rename command:

    brew install rename

    Tree command for mac:

    brew install tree

    Install wget:

    brew install wget --enable-iri

    See [.brew](https://github.com/addyosmani/dotfiles/blob/master/.brew) for more information