Skip to content

Instantly share code, notes, and snippets.

@7hunderbird
Forked from niepi/osx_php_homebrew.setup.md
Last active December 21, 2015 21:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7hunderbird/6371966 to your computer and use it in GitHub Desktop.
Save 7hunderbird/6371966 to your computer and use it in GitHub Desktop.

install php

By default this version of homebrew has both Apache and MySQL support so we only need to add International support option.

brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php
brew update
Removed ~/.pearrc
Installed XQuartz-2.7.4.dmg
brew install php55 
brew install php55-intl

Install log: https://gist.github.com/7hunderbird/dcdd73e71daa8b141f33

set php timezone in php ini

subl /usr/local/etc/php/5.5/php.ini
date.timezone = America/Denver

install apache2

brew tap djl/homebrew-apache2
brew install djl/apache2/apache24

Install log: https://gist.github.com/7hunderbird/0b7d974bfde23098064c

load php module in apache

subl /usr/local/etc/apache2/httpd.conf
LoadModule php5_module /usr/local/opt/php55/libexec/apache2/libphp5.so

operate apache

sudo apachectl start
sudo apachectl restart

Set ServerName to localhost to avoid error on restart

ServerName localhost:80

fix pear permissions and config

chmod -R ug+w /usr/local/Cellar/php55/5.5.3/lib/php
pear config-set php_ini /usr/local/etc/php/5.5/php.ini

setup a site

mkdir -p /usr/local/var/apache2/htdocs/www/example.com/public_html
chown -R daemon:daemon /usr/local/var/apache2/htdocs/www/example.com/public_html 
chmod -R 755 /usr/local/var/apache2/htdocs/www/
subl /usr/local/var/apache2/htdocs/www/example.com/public_html/index.html # create a default page

default page

<html>
  <head>
    <title>www.example.com</title>
  </head>
  <body>
    <h1>Success: You Have Set Up a Virtual Host</h1>
</body>
</html>

Create the New Virtual Host File

mkdir -p /usr/local/etc/apache2/sites-available/
subl /usr/local/etc/apache2/sites-available/example.com

Virtual host file for example.com

<VirtualHost *:80>
    ServerAdmin tyler.bird@gmail.com
    DocumentRoot "/usr/local/var/apache2/htdocs/www/example.com/public_html"
    ServerName example.com
    ErrorLog "/usr/local/var/log/apache2/example.com-error_log"
    CustomLog "/usr/local/var/log/apache2/example.com-access_log" common
</VirtualHost>

Resource

install mysql

brew install mysql

Install log: https://gist.github.com/7hunderbird/47b1e7c789d69f199932

install mysql default tables

unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp	

set mysql up to start automatically on system boot:

mkdir -p ~/Library/LaunchAgents
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

mysql commands

mysql.server start
mysql.server stop

Stuff I'm Not Using Yet

From here down this is stuff I'm not using yet because I am not super advanced into PHP yet. But I'll hold on to it until later.

install xdebug & apc

if you don't have autoconf (Xcode 4.3) install autoconf

brew install autoconf 
pecl install xdebug apc

xdebug setup

and change

extension=xdebug.so

to

zend_extension="$fullpath/xdebug.so"
xdebug.remote_enable = On
xdebug.remote_autostart = 1

install pear packages

php q/a tools

pear config-set auto_discover 1
pear install pear.phpqatools.org/phpqatools pear.netpirates.net/phpDox

this will install:

PHP_Depend, PHP_CodeSniffer, File_Iterator Text_Template, PHP_Timer, YAML, Console_CommandLine, Log, PHP_TokenStream, Base, PHP_PMD, PHP_CodeBrowser, PHP_CodeCoverage, PHPUnit_MockObject, ConsoleTools, PHPUnit, phpcpd, phploc, phpqatools

install phing

pear channel-discover pear.phing.info
pear config-set preferred_state beta
pear install phing/phing
pear config-set preferred_state stable

resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment