Skip to content

Instantly share code, notes, and snippets.

@caffeineinc
Last active September 29, 2020 03:14
Show Gist options
  • Select an option

  • Save caffeineinc/0371dad086b4f26cc9c7b4e2ea03bedb to your computer and use it in GitHub Desktop.

Select an option

Save caffeineinc/0371dad086b4f26cc9c7b4e2ea03bedb to your computer and use it in GitHub Desktop.

MacOS configurations:

show all files (requires finder restart)

defaults write com.apple.finder AppleShowAllFiles YES

disable shitty back forward behavoiour.

defaults write com.google.Chrome.plist AppleEnableSwipeNavigateWithScrolls -bool FALSE

Install brew:

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

Install git:

brew install git

install mariadb

brew install mariadb

install composer

brew install homebrew/php/composer

install npm

brew install npm

install yarn

brew install yarn

install mcrypt

brew install mcrypt

install http24

sudo apachectl stop sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null brew install -v httpd --with-brewed-openssl --with-mpm-event --with-apache --with-included-apr --with-privileged-ports --with-http2

cd /usr/local/etc/apache2/2.4 openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt

install php

brew install php56 --with-httpd --build-from-source --with-thread-safety

Update php ini php -i | grep ini vim /usr/local/etc/php/5.6/php.ini -> update memory_limit - 256 memory_limit = 256M

date.timezone = Pacific/Auckland

install x-debug

brew install php56-xdebug brew install xdebug-osx

https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions https://getgrav.org/blog/macos-sierra-apache-mysql-vhost-apc

echo " xdebug.remote_enable=true xdebug.idekey=PHPSTORMCONSOLE" >> /usr/local/etc/php/5.6/conf.d/ext-xdebug.ini

add vhosts:

open -e /usr/local/etc/apache2/2.4/httpd.conf

add php56 LoadModule php5_module /usr/local/Cellar/php56/<your php location>/libexec/apache2/libphp5.so

uncomment proxy_module rewrite_module ssl_module expires_module

error log: "/usr/local/var/log/apache2/error_log"

change LogLevel warn to LogLevel debug and reference httpd conf in your sites for reference

ln -s /usr/local/etc/apache2/2.4/httpd.conf ~/Sites/httpd.conf

add your DocumentRoot

<Directory "/Users/simongow/Sites/">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options FollowSymLinks Multiviews
    MultiviewsMatch Any

    #
    # 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

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
    RewriteEngine On
  
    RewriteBase /

    SetEnv BaseUrl '/'

    # Store the current location in an environment variable CWD
    RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
    RewriteRule ^.*$ - [E=CWD:%2]

    # Just by prefixing the environment variable, we can safely rewrite anything now
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^.*$ %{ENV:CWD}framework/main.php [QSA,L]
    SetEnvIf REQUEST_URI (^/?[a-z]+) BaseUrl=$1
    SetEnv SS_ENVIRONMENT_FILE '../_ss_environment.php'

    RewriteBase / 
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
    RewriteRule ^.*$ %2framework/main.php?url=%1 [QSA]

</Directory>

install dnsmasq

brew install dnsmasq mkdir -pv $(brew --prefix)/etc/ Add to resolvers

Create resolver directory

sudo mkdir -v /etc/resolver

Add your nameserver to resolvers

sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/dev'

Add local DNS to search order in System Preferences

System Preferences > Network > Wi-Fi (or whatever you use) > Advanced... > DNS > add 127.0.0.1 to top of the list.

restart dnsmasq to get new settings

sudo brew services restart dnsmasq

test Dnsmasq by sending it a DNS query using the dig utility. Pick a name ending in dev and use dig to query your new DNS server:

dig testing.testing.one.two.three.dev @127.0.0.1

install docker

https://docs.docker.com/docker-for-mac/install/#download-docker-for-mac

Create docker config:

  • touch ~/Sites/docker.yml
  • mysql dir: /usr/local/var/mysql
version: '3'
services:
  web:
    image: brettt89/silverstripe-web
    working_dir: /Users/<your_home_dir>/Sites
    volumes:
      - .:/Users/<your_home_dir>/Sites
    environment:
      - VIRTUAL_HOST=project1.dev
  database:
    image: mysql
    volumes:
      - db-data:<your_mysql_data_dir>
    restart: always
    environment:
      - MYSQL_ALLOW_EMPTY_PASSWORD=true
volumes:
  db-data:
networks:
  default:
    external:
      name: my-network

ln -s /Applications/Docker.app/Contents/Resources/etc/docker.bash-completion /usr/local/etc/bash_completion.d/docker ln -s /Applications/Docker.app/Contents/Resources/etc/docker-machine.bash-completion /usr/local/etc/bash_completion.d/docker-machine ln -s /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion /usr/local/etc/bash_completion.d/docker-compose

console access

docker-compose exec web /bin/bash

Logs: /var/logs/apache2/

Create a docker network for your projects

$ docker network create my-network This will act as a global network for each of your projects to run in simultaniously

Run nginx-proxy in your network

$ docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro --net my-network --name nginx-proxy brettt89/nginx-proxy Nginx proxy will act as a gateway for all the project environments. For best results it is recommended to use a shared root domain for each project. E.g. dev

find the proxyIP and put it into dns masq

docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nginx-proxy | awk '{print "address=/.dev/"$1}' > $(brew --prefix)/etc/dnsmasq.conf

add keboard shortcut for zoom all

preferences -> keyboard -> app shortcuts -> + -> "Zoom All" -> "option command `"

misc

brew install nvm

post install

docker --version docker-machine --version docker-compose --version

Install seige & reduce default port timeout to a second

brew install zlib brew install --build-from-source siege

# sysctl net.inet.tcp.msl net.inet.tcp.msl: 15000

# sudo sysctl -w net.inet.tcp.msl=1000 net.inet.tcp.msl: 15000 -> 1000

Install locust

brew install libev curl https://bootstrap.pypa.io/get-pip.py > /var/tmp/get-pip.py sudo python /var/tmp/get-pip.py sudo easy_install locustio

Install bash completion

brew install bash-completion

$ brew install bash-completion $ brew tap homebrew/completions

add to .bash_profile:

. $(brew --prefix)/etc/bash_completion
fi```

# install sspak
https://silverstripe.github.io/sspak/

# install JDK (urgh) 

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment