-
-
Save jdaily/7860382 to your computer and use it in GitHub Desktop.
Brewing my Dev Environment - PHP, Ruby, Scala, Nginx, Play Framework, Node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Xcode | |
Install Xcode | |
Head to the Apple Developer Center to download a copy of the latest Xcode | |
* [Apple Developer Center](http://developer.apple.com/technologies/xcode.html) | |
xcode-select --install | |
## Sublime Text 3 | |
Install Package Control (View > Show Console) | |
import urllib.request,os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read()) | |
Install CSSlint, JSONlint | |
## Homebrew | |
Install [Homebrew](https://github.com/mxcl/homebrew) | |
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" | |
Export Brew directory in your PATH | |
echo export PATH="/usr/local/sbin:$PATH" >> ~/.bash_profile | |
## Git | |
Install Git | |
brew install git | |
You will also want to setup your Git and GitHub user details | |
### Setting user name and email globally in git | |
git config --global user.name "adamstac" | |
git config --global user.email "adam@stacoviak.com" | |
### GitHub token config | |
git config --global github.user adamstac | |
git config --global github.token 0123456789abcdef0123456789abcdef | |
### Git aliases | |
Setup common git aliases. | |
git config --global alias.co checkout | |
git config --global alias.br branch | |
git config --global alias.ci commit | |
git config --global alias.st status | |
## MySQL | |
Next we need to install MySQL. Yes, it's really this easy ... but this will take a while. | |
brew install mysql | |
Now to warm it up: | |
mysql_install_db | |
After you run `mysql_install_db` you'll see output like this ... | |
Installing MySQL system tables... | |
OK | |
Filling help tables... | |
OK | |
To start mysqld at boot time you have to copy | |
support-files/mysql.server to the right place for your system | |
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! | |
To do so, start the server, then issue the following commands: | |
./bin/mysqladmin -u root password 'new-password' | |
./bin/mysqladmin -u root -h AS-MBP15.local password 'new-password' | |
Alternatively you can run: | |
./bin/mysql_secure_installation | |
which will also give you the option of removing the test | |
databases and anonymous user created by default. This is | |
strongly recommended for production servers. | |
See the manual for more instructions. | |
You can start the MySQL daemon with: | |
cd . ; ./bin/mysqld_safe & | |
You can test the MySQL daemon with mysql-test-run.pl | |
cd ./mysql-test ; perl mysql-test-run.pl | |
Please report any problems with the ./bin/mysqlbug script! | |
When that's done, make sure MySQL automatically starts on login: | |
launchctl load -w /usr/local/Cellar/mysql/VERSION/com.mysql.mysqld.plist | |
## Gradle 1.9 | |
`` | |
cd $( brew --prefix ) | |
brew versions gradle | |
git checkout 5bab5e9 Library/Formula/gradle.rb | |
brew install gradle | |
`` | |
## PHP | |
Install PHP | |
brew rm php55 && brew deps | |
brew tap homebrew/dupes | |
brew tap homebrew/versions | |
brew tap homebrew/php | |
brew install --without-apache --with-fpm --with-mysql --with-debug --with-debug --with-curl php55 | |
brew install php55-mcrypt | |
brew install php55-mongo | |
brew install phpmyadmin | |
Set PHP-FPM to start on boot | |
ln -sfv /usr/local/opt/php55/*.plist ~/Library/LaunchAgents | |
Start PHP-FPM | |
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist | |
Install composer | |
brew install composer | |
Install GEOS | |
brew install phpunit gdal | |
wget http://download.osgeo.org/geos/geos-3.4.2.tar.bz2 | |
tar -xjvf geos-3.4.2.tar.bz2 | |
cd geos-3.4.2/ | |
./configure --enable-php | |
make | |
sudo make install | |
``` | |
cat > /usr/local/etc/php/5.5/conf.d/geos.ini << EOF | |
; configuration for php geos module | |
; priority=50 | |
extension=geos.so | |
EOF | |
``` | |
## NGINX | |
Install Nginx | |
brew install nginx | |
Configure Nginx | |
mkdir /usr/local/etc/nginx/sites-enabled/ | |
sed -i -e "s/#gzip on;/gzip on; include \/usr\/local\/etc\/nginx\/sites-enabled\/*;/g" /usr/local/etc/nginx/nginx.conf | |
mkdir /usr/local/var/run/php | |
sed -i -e "s/listen = 127.0.0.1:9000/listen = \/usr\/local\/var\/run\/\php\/php5-fpm.sock;listen = 127.0.0.1:9000/g" /usr/local/etc/php/5.5/php-fpm.conf | |
Restart nginx | |
sudo nginx -s stop | |
sudo nginx | |
Sample PHP nginx config | |
location ~ \.php$ { | |
try_files $uri =404; | |
include fastcgi_params; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
#Use sockets, reduces tcp overhead | |
fastcgi_pass unix:/usr/local/var/run/php/php5-fpm.sock; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_index index.php; | |
} | |
## Scala | |
brew install scala --with-docs | |
brew install sbt | |
brew install play | |
brew install drip | |
brew install android-sdk | |
#Add to bash profile | |
export JAVA_HOME=$(/usr/libexec/java_home) | |
export SCALA_HOME=/usr/local/Cellar/scala/2.10.3/libexec/ | |
export JAVACMD=drip | |
export DRIP_SHUTDOWN=30 | |
export SBT_OPTS="-XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:PermSize=128M -XX:MaxPermSize=512M" | |
## Redis | |
brew instal redis | |
#Start | |
launchctl load -w /usr/local/Cellar/redis/2.8.2/homebrew.mxcl.redis.plist | |
## Node | |
brew install node | |
## cocoapods | |
sudo gem install cocoapods | |
Install pods from pod file | |
pod install | |
## RVM | |
Install RVM | |
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm) | |
Next you have to add RVM to your `.bash_profile`. [See also](https://gist.github.com/391848) for an example `.bash_profile` file. | |
# place in ~/.bash_profile as the very last line | |
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" | |
To check everything went well | |
type rvm | head -n1 | |
To seamlessly abandon the Apple-installed system ruby (ruby 1.8.7 patchlevel 174 for Snow Leopard): | |
rvm install 1.8.7 # installs 1.8.7-p334 | |
rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system # migrate your gems | |
rvm --default 1.8.7 | |
If you are planning to do development that requires ruby-1.9.2, you need to install 1.9.2 as well. | |
rvm install 1.9.2 | |
## SSH keys | |
Generating SSH keys (OSX) | |
First check to see if a ssh key directory exists. | |
cd ~/.ssh | |
ls -lash | |
If nothing is listed, then you can move on - or else you'll need to backup the existing key and create a new as needed. | |
ssh-keygen -t rsa -C "adam@stacoviak.com" | |
You should see something like this. | |
Generating public/private rsa key pair. | |
Enter file in which to save the key (/Users/astacoviak/.ssh/id_rsa): | |
Enter passphrase (empty for no passphrase): | |
Enter same passphrase again: | |
Your identification has been saved in /Users/astacoviak/.ssh/id_rsa. | |
Your public key has been saved in /Users/astacoviak/.ssh/id_rsa.pub. | |
The key fingerprint is: | |
08:49:4b:84:c6:b0:2c:9e:dc:aa:b4:b2:ba:d8:0f:52 adam@stacoviak.com | |
The key's randomart image is: | |
+--[ RSA 2048]----+ | |
|.o o+ | | |
|.++o o | | |
|oo + | | |
|+ o . . | | |
| +A. . S | | |
| .. | | |
|.o. | | |
|=o+. | | |
|O++.. | | |
+-----------------+ | |
## Bundler | |
Install Bundler | |
gem install bundler | |
If you're on an old version of Rubygems | |
sudo gem update --system | |
Setup your .gemrc | |
echo -e '--- | |
:benchmark: false | |
gem: --no-ri --no-rdoc | |
:update_sources: true | |
:bulk_threshold: 1000 | |
:verbose: true | |
:sources: | |
- http://rubygems.org | |
:backtrace: false' > ~/.gemrc | |
## Aliases | |
You likely have a number of servers that you use. Open up `~/.ssh/config` and create some aliases to those servers. | |
Host clientname_staging | |
HostName staging.clientdomain.com | |
User developer | |
Host clientname_production | |
HostName clientdomain.com | |
User developer | |
## Install Docker | |
brew tap phinze/homebrew-cask | |
brew install brew-cask | |
brew cask install virtualbox | |
brew install boot2docker | |
boot2docker init | |
boot2docker up | |
brew install docker | |
--- | |
## Sources | |
* [Installing and Using Rvm on Mac OS X, Creating Gemsets and Reverting to Original Environment](http://seanbehan.com/mac-os-x/installing-and-using-rvm-on-mac-os-x-creating-gemsets-and-reverting-to-original-environment/) | |
* [Generating SSH keys (OSX)](http://help.github.com/mac-key-setup/) | |
* [Bundler](http://gembundler.com/) | |
* [Homebrew](https://github.com/mxcl/homebrew) | |
* [Apple Dev Center](https://developer.apple.com/) | |
* [2009 Rubyist’s guide to a Mac OS X development environment](http://robots.thoughtbot.com/post/159805668/2009-rubyists-guide-to-a-mac-os-x-development) | |
* [RVM](http://rvm.beginrescueend.com/) | |
* [Setting user name, email and GitHub token](http://help.github.com/git-email-settings/) | |
* [Configuring PHP and Nginx] (https://coderwall.com/p/lbaf6q) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment