Skip to content

syzygypl/mac-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mac setup with Ansible

Build Status

$ curl -sL https://raw.githubusercontent.com/syzygypl/mac-setup/master/bootstrap.sh | bash

This script will setup your Mac with software that we use in Syzygy Warsaw on a daily basis. All You need is paste above line to Terminal and execute.

It will install Apache 2.4 and PHP 5.6, 7.1 and 7.2 with required extensions and configure sites to be served from ~/Sites/*.loc/web directories. DNS records of *.loc are being handled by Dnsmasq so no changes in /etc/hosts are required.

You can check software being installed below. If no version is provided - we use the newest.

Apps

Window-less software

Configuration

PHP

/usr/local/etc/php/*/php.ini:

upload_max_filesize   20M
post_max_size         80M
memory_limit          10G
date.timezone         'Europe/Warsaw'

Apache

/usr/local/etc/httpd/httpd.conf:

LoadModule  vhost_alias_module  libexec/mod_vhost_alias.so
LoadModule  rewrite_module      libexec/mod_rewrite.so
LoadModule  php5_module         /usr/local/opt/php@5.6/lib/httpd/modules/libphp5.so
LoadModule  php7_module         /usr/local/opt/php@7.1/lib/httpd/modules/libphp7.so
LoadModule  php7_module         /usr/local/opt/php@7.2/lib/httpd/modules/libphp7.so

Include     /usr/local/etc/httpd/extra/httpd-vhosts.conf
Include     /usr/local/etc/httpd/extra/httpd-php.conf

User        {{ ansible_ssh_user }}
Group       staff
ServerName  {{ ansible_hostname }}.local

/usr/local/etc/apache2/2.4/extra/httpd-vhosts.conf:

<Directory /Users/{{ ansible_ssh_user }}/Sites>
  Require all granted
  AllowOverride All
  DirectoryIndex index.php index.html
</Directory>

<VirtualHost *:80>
  DocumentRoot /Users/{{ ansible_ssh_user }}/Sites/
</VirtualHost>

<VirtualHost *:80>
  ServerName loc
  ServerAlias *.loc

  CustomLog /var/log/apache2/loc.access_log vcommon
  ErrorLog /var/log/apache2/loc.error_log
  VirtualDocumentRoot /Users/{{ ansible_ssh_user }}/Sites/%-2.0.%-1.0/web/

  LogFormat "%{Host}i %l %u %t \"%r\" %>s %b" vcommon
  Options +FollowSymLinks
  DirectoryIndex index.php
  FallbackResource /index.php

  SetEnvIf Request_URI ^ Debug=1 DEBUG=1 SYMFONY_ENV=dev APP_ENV=dev
  SetEnvIf Host ([^\.]+).loc APP_NAME=$1
  SetEnvIf Host app.([^\.]+) APP_NAME=$1
  SetEnvIf Cookie "APP_NAME=(\w+)" APP_NAME=$1

</VirtualHost>

# Additional VirtualHosts
IncludeOptional /usr/local/etc/httpd/vhosts/*.conf

/usr/local/etc/httpd/httpd-php.conf:

<FilesMatch \.php$>
  SetHandler application/x-httpd-php
</FilesMatch>

Dnsmasq

/etc/resolver/loc:

nameserver 127.0.0.1

/usr/local/etc/dnsmasq.conf:

address=/.loc/127.0.0.1

Services

All services are managed via brew services command.

$ brew services list

Name              Status  User Plist
dnsmasq           started root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
elasticsearch@5.6 started kuba /Users/kuba/Library/LaunchAgents/homebrew.mxcl.elasticsearch@5.6.plist
httpd             started root /Library/LaunchDaemons/homebrew.mxcl.httpd.plist
mongodb           started kuba /Users/kuba/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
mysql@5.7         started kuba /Users/kuba/Library/LaunchAgents/homebrew.mxcl.mysql@5.7.plist
php               stopped
php@5.6           stopped
php@7.1           stopped
redis             started kuba /Users/kuba/Library/LaunchAgents/homebrew.mxcl.redis.plist

dnsmasq and apache should be started as root:

$ sudo brew services start httpd
==> Successfully started `httpd` (label: homebrew.mxcl.httpd)

$ sudo brew services start dnsmasq
==> Successfully started `dnsmasq` (label: homebrew.mxcl.dnsmasq)

Rest can be started as regular user (no sudo required):

$ brew services start redis
==> Successfully started `redis` (label: homebrew.mxcl.redis)

$ brew services start elasticsearch@5.6
==> Successfully started `elasticsearch@5.6` (label: homebrew.mxcl.elasticsearch@5.6)

$ brew services start mysql@5.7
==> Successfully started `mysql@5.7` (label: homebrew.mxcl.mysql@5.7)

Other commands available for brew services are restart and stop.

Cleanup old brew PHP

$ brew update
$ brew upgrade
$ brew cleanup

# check what packages are installed
$ brew list | grep php

# uninstall old php packages
$ brew uninstall --force php56 php56-apcu php56-opcache php56-xdebug php56-yaml php56-igbinary php56-intl php56-redis php56-imagick php56-mcrypt
$ brew uninstall --force php70 php70-apcu php70-opcache php70-xdebug php70-yaml php70-igbinary php70-intl php70-redis php70-imagick php70-mcrypt
$ brew uninstall --force php71 php71-apcu php71-opcache php71-xdebug php71-yaml php71-igbinary php71-intl php71-redis php71-imagick php71-mcrypt
$ brew uninstall --force php72 php72-apcu php72-opcache php72-xdebug php72-yaml php72-igbinary php72-intl php72-redis php72-imagick php72-mcrypt
$ brew cleanup

# check if everything was uninstalled Successfully
$ brew list | grep php

# remove old configs
$ rm -Rf /usr/local/etc/php/*