Setting up a new mac - notes

Submitted by michael on Wed, 01/02/2019 - 15:18

My notes on setting up a new mac, probably only useful for me. 

Make a backup

  1. mysqldump to get the database stuff.
  2. Export the eXist-db content.
  3. Force a time machine backup or something like it.

Pave and clean the hard drive

  1. Use the AppStore to download the new OS. It will autostart the install - don't let it install.
  2. Make a start-up thumb drive.
    sudo /Applications/Install\ macOS\ --volume /Volumes/WHATEVER
  3. Reboot and hold down the option key to bring up a boot manager page.
  4. Use Disk Utility to format the drive. APFS is the new hotness.
  5. After the machine reboots a few time walk through the install process. iCloud is garbage and will only cause problems. Dark mode is nice.
  6. Futz with the system preferences and finder views.

Developer tools

This part was really easy a few years ago, but now that Apple's so paranoid about security it's a pain.

  1. Open a terminal and type xcode-select --install. That'll get the developer tools installed. I don't need XCode for anything I do.
  2. Install Homebrew.
    /usr/bin/ruby -e "$(curl -fsSL"
  3. Generate an SSH key pair.
    ssh-keygen -t rsa
  4. Add the ssh public key to Github and clone my dot-files & dot-emacs from github.
  5. ./ for the dot-files, make for the dot-emacs.
  6. brew bundle install. It'll fail the first time with permissions errors on pkgconfig. Dunno what that's about, but sudo chown -R $(whoami) /usr/local/lib/pkgconfig should fix it.

Configure Apache

I want Apache to listen on port 80 because I'm lazy and forget the :8080 part of dev URLs.

  1. mkdir ~/Sites - apache will not start if you set DocumentRoot to a path that doesn't exist.
  2. Edit /usr/local/etc/httpd/httpd.conf as follows:
    1. Change Listen 8080 to Listen 80
    2. Enable rewrite_module
    3. Change User and Group to your username and nobody.
    4. Set the ServerName to localhost
    5. Set the DocumentRoot to /Users/username/Sites
    6. Configure the Directory /Users/username/Sites like so:
      1. Options All FollowSymLinks Multiviews
      2. MultiviewsMatch Any
      3. AllowOverride All
  3. restart apache and check that a page in ~/Sites loads.

Configure PHP

No need to use php-fpm. It's fast, but the config is a too much. The Apache module is enough here.

  1. brew services stop php and then brew services cleanup. Probably not necessary in a fresh install, but no harm done.
  2. Add LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/ to httpd.conf and restart apache. This makes switching PHP 7 versions easy. Adjust for PHP 5 as necessary.
  3. Add a file match for PHP
      SetHandler application/x-httpd-php 
  4. Add a directory index file for PHP
    DirectoryIndex index.php index.html
  5. echo " ~/Sites/info.php and visit http://localhost/info.php to make sure it works.

Configure MySQL

  1. brew services start mysql
  2. I have a .my.cnf in my home directory with a username/password combo. mysql -u root and leave the password blank to get around it. Should get a mysql> shell.
  3. mysql_secure_installation
  4. mysql should get you a shell.
  5. Configure the daemon
    bind-address =
    socket = /tmp/mysql.sock
    log_error = /usr/local/var/log/mysql/error.log
    log_error_verbosity = 2
    general_log = 0
    general_log_file = /usr/local/var/log/mysql/mysql.log
    slow_query_log = 0
    slow_query_log_file = /usr/local/var/log/mysql/slow.log
    max_allowed_packet = 16M
  6. mysql should now work. Check perms and existence of /usr/local/var/log/mysql if it fails and try again.