Skip to content

Instantly share code, notes, and snippets.

@slavcodev
Forked from mystix/setup-php-dev.sh
Created October 20, 2013 19:00
Show Gist options
  • Select an option

  • Save slavcodev/7073765 to your computer and use it in GitHub Desktop.

Select an option

Save slavcodev/7073765 to your computer and use it in GitHub Desktop.
#!/bin/bash
# install homebrew's official php tap
brew tap josegonzalez/homebrew-php
# install nginx + mysql + php 5.3 + php-fpm + apc + xdebug
brew install nginx mysql
brew install --without-apache --with-suhosin --with-fpm --with-mysql php53
brew install php53-apc php53-xdebug
# add apc + xdebug configs to php.ini:
echo "
[apc]
extension = \"`brew --prefix php53-apc`/apc.so\"
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 64M
apc.ttl = 7200
apc.user_ttl = 7200
apc.num_files_hint = 1024
apc.mmap_file_mask = /tmp/apc.XXXXXX
apc.enable_cli = 1
[xdebug]
zend_extension = \"`brew --prefix php53-xdebug`/xdebug.so\"
xdebug.remote_enable = 1
; use port 9009 because php-fpm uses 9000 by default
xdebug.remote_port = 9009
" >> /usr/local/etc/php/5.3/php.ini
# set up mysql to run as user account
unset TMPDIR
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
# launch mysql on startup
cp `brew --prefix mysql`/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
# launch php-fpm on startup
cp `brew --prefix php53`/homebrew-php.josegonzalez.php53.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php53.plist
# launch nginx at startup as root (in order to listen on privileged port 80):
sudo cp `brew --prefix nginx`/homebrew.mxcl.nginx.plist /Library/LaunchDaemons/
sed -i -e 's/`whoami`/root/g' `brew --prefix nginx`/homebrew.mxcl.nginx.plist
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
echo "
POST-INSTALL PROCEDURE:
=======================
1) configure intellij / netbeans / phpstorm / eclipse pdt to connect to xdebug on port 9009
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment