User:Brooke Vibber/Mac homebrew setup

From mediawiki.org

Some notes on installation on macOS High Sierra using Homebrew for dependencies; then follow directions from Download from Git to get stuff.

Avoiding using Apple's provided PHP and Apache packages as they often get surprise-broken on upgrades.

Dependencies[edit]

Homebrew[edit]

  • Install Xcode from App Store
  • xcode-select --install
  • Install brew from directions at https://brew.sh/

Core[edit]

Apache:

  • brew install httpd

PHP:

  • brew tap homebrew/homebrew-php
  • brew install php72 --with-httpd
  • manually edit /usr/local/etc/httpd/httpd.conf as described in the above to enable .php files
  • brew install php72-intl
  • (optional if not using memcached)
    • brew install php72-apcu

Composer:

  • brew install composer

MySQL:

  • brew install mysql

Memcached:

  • (optional, but recommended since APCu's in-process cache won't be available to CLI scripts such as job queue)
  • brew install memcached

ImageMagick:

  • brew install ImageMagick

TimedMediaHandler[edit]

ffmpeg must be installed with libvorbis, libvpx, opus, and theora enabled manually:

  • brew install ffmpeg --with-libvorbis --with-libvpx --with-opus --with-theora

Control[edit]

Start:

  • brew services start mysql
  • brew services start memcached
  • brew services start httpd

Stop:

  • brew services stop httpd
  • brew services stop memcached
  • brew services stop mysql

Job queue:

  • cd /path/to/wiki && php maintenance/runJobs.php --wait
    • runs in foreground
    • fixme: get a reasonable runner and include it

Security[edit]

The web and database servers will run as your regular user account unless you change it. This may be "surprising" for security but is kind of convenient for development work, as command-line manipulation of your files is the same.

Apache binds to port 8080 on all interfaces by default. This can be locked to localhost by editing httpd.conf

MySQL installs without a root password by default, but is local-only (no network port enabled).

If enabling uploads, consider disabling PHP execution in the images/ dir of the checkout, etc.

Notes[edit]

The default web root is /usr/local/var/www; you can check out git in there, or edit httpd.conf to define another document root or subdir.

Depending on local configuration, the PATH variable may put Apple's PHP before the homebrew one in path... May have to override such as:

  • export PATH="$(brew --prefix homebrew/php/php72)/bin:$PATH"