Skip to content

Instantly share code, notes, and snippets.

@barlas
Forked from offsky/NewMacConfig.md
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barlas/380e4fd915db2ec65420 to your computer and use it in GitHub Desktop.
Save barlas/380e4fd915db2ec65420 to your computer and use it in GitHub Desktop.
Setup new mac for web development (Updated for Yosemite)

##Install Xcode command line tools

Xcode>Preferences>Downloads

Enable root if not already enabled: http://support.apple.com/kb/PH11331?viewlocale=en_US

##Apache

Apache is already installed, just not running.

apachectl start
apachectl stop
apachectl restart

To get it to work with user directories, replace "username" with your username. The file may already be there

nano /etc/apache2/users/username.conf

Add and save this info into that file.

<Directory "/Users/username/Sites/">
    Options Indexes MultiViews
    AllowOverride All
    Options +FollowSymLinks
    Require all granted
    Allow from all
</Directory>

It should already have the right permissions, but if not:

chmod 644 username.conf

You may also need to create the /username/Sites directory

nano /etc/apache2/httpd.conf

Uncomment: LoadModule userdir_module libexec/apache2/mod_userdir.so Uncomment: Include /private/etc/apache2/extra/httpd-userdir.conf

nano /etc/apache2/extra/httpd-userdir.conf 

Uncomment: Include /private/etc/apache2/users/*.conf

apachectl restart

Now go to http://localhost/~username and it should work. Drop in phpinfo() and it won't work yet.

Apache error logs: /private/var/log/apache2/error_log

##PHP

nano /etc/apache2/httpd.conf

Uncomment: LoadModule php5_module libexec/apache2/libphp5.so

create /etc/php.ini or copy it from the default in /etc

Restart apache and php should work now

Install Xdebug by addind the following line in php.ini

zend_extension = "xdebug.so"

Other changes

error_reporting = E_ALL | E_STRICT 
error_log = /path/to/my/php_error.log
short_open_tag = On

Install mcrypt : http://www.glenscott.co.uk/blog/install-mcrypt-php-extension-on-mac-os-x-lion/ http://coolestguidesontheplanet.com/install-mcrypt-php-mac-osx-10-9-mavericks-development-server/

##Homebrew http://mxcl.github.com/homebrew/

##Install Autoconf This may not be necessary for all systems, but it will prevent later steps from failing

sudo chown -R `whoami` /usr/local
brew install autoconf

##Install Pear/Pecl

cd /usr/lib/php
sudo php install-pear-nozlib.phar
sudo pear channel-update pear.php.net
sudo pecl channel-update pecl.php.net
sudo pear config-set php_ini /private/etc/php.ini
sudo pecl config-set php_ini /private/etc/php.ini  
sudo pear upgrade-all
sudo pear config-set auto_discover 1

Edit /etc/php.ini and find the line:

;include_path = ".:/php/includes"

and change it to


include_path = ".:/usr/lib/php/pear"

##Install Optional Pear libraries

pear config-set auto_discover 1
pear install PHP_CodeSniffer
pear install pear.phpunit.de/phploc
pear channel-discover pear.phpmd.org
pear channel-discover pear.pdepend.org
pear install --alldeps phpmd/PHP_PMD

Ref: http://pear.php.net/package/PHP_CodeSniffer/docs

https://github.com/sebastianbergmann/phploc

http://phpmd.org

##PHPUnit PHPUnit with PHPUnit_TicketListener_GitHub For each project, create a phpunit.xml.dist file and test that you can run phpunit from the command line

##Install Phing

pear channel-discover pear.phing.info
pear install phing/phing

Create build.xml file for each project and confirm that you can run phing from the command line

##Jenkins

Install Jenkins

Install following plugins for jenkins by going to Jenkins and clicking "Manage Jenkins" and then "Manage Plugins"

  • phing plugin
  • Checkstyle
  • CloverPHP
  • HTML Publisher
  • JDepend
  • Plot
  • PMD
  • Violations
  • Github
  • Git

Need to do some mac specific stuff: http://momo.brauchtman.net/2011/11/12/howto-install-jenkins-on-os-x-and-make-it-build-mac-stuff/ http://jenkins-php.org http://marcelog.github.com/articles/ciconfigexample.jpeg

##Mongo drivers

brew install autoconf
pecl install mongo

Add to /etc/php.ini : extension=mongo.so

##Install Karma http://karma-runner.github.io/0.8/index.html

brew install phantomjs
npm install karma

##Plugins Install LiveReload from AppStore.

Install browser plugins: http://feedback.livereload.com/knowledgebase/articles/86242-how-do-i-install-and-use-the-browser-extensions-

Install AngularJS Batarang Chrome Plugin: https://github.com/angular/angularjs-batarang

##Sublime Text 2 Install Sublime Text 2.

Install Package Control Plugin: http://wbond.net/sublime_packages/package_control/installation

Install popular plugins using "Preferences > Package Control > Install Package"

  • AngularJS
  • Additional PHP Snippets
  • Goto Documentation (Add a keybinding for it in "Preferences > Key Bindings - User") { "keys": ["super+`"], "command": "goto_documentation" }
  • Theme-Soda
  • Phix Color Scheme
  • Sublimelinter (for contextual linting of JS, CSS and PHP) https://github.com/SublimeLinter/SublimeLinter
  • sublime-closure-linter (for console linting and auto-fix menu command)
  • SideBarEnhancements
  • ColorPick

Edit "Preferences > Settings > user"

"color_scheme": "Packages/Phix Color Scheme/Phix Dark.tmTheme",
"theme": "Soda Dark.sublime-theme",
"tab_size": 3

Install subl command line utility.

ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /bin/subl

Install closure linter https://developers.google.com/closure/utilities/docs/linter_howto

sudo easy_install http://closure-linter.googlecode.com/files/closure_linter-latest.tar.gz

Edit SublimeLinter settings:

"sublimelinter_mark_style": "none",
...
"sublimelinter_gutter_marks": true,
...
"javascript_linter": "gjslint",
...
"gjslint_ignore":
    [
        110,  // line too long
        5 //tab instead of space
    ],

Edit sublinme-closure-linter settings:

{
    "gjslint_path": "/usr/local/bin/gjslint",
    "gjslint_flags": "",
    "fixjsstyle_path": "fixjsstyle",
    "fixjsstyle_flags": "",
    "ignore_errors":
    [
        // Ignore errors, regex.
        // "Expected an identifier and instead saw 'undefined' \(a reserved word\)"
        "Illegal tab",
        "Line too long"
    ],
    "debug": false,
    "run_on_save": true
}

Reference: http://blog.stuartherbert.com/php/2012/02/28/setting-up-sublime-text-2-for-php-development/

##Mysql Download dmg from http://dev.mysql.com/downloads/mysql/ Install Start mysql from system preferneces panel Set password and socket:

/usr/local/mysql/bin/mysqladmin -u root password 'yourpassword'
mkdir /var/mysql
sh-3.2# sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

Make user

mysql
GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Update this in phpmyadmin and in db config file ##Reference https://gist.github.com/1623487

http://php.dzone.com/articles/setting-php-and-mysql-os-x-108

http://marcelog.github.com/articles/ci_jenkins_hudson_continuous_integration_php_phing.html

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