Start by downloading and installing XCode 4.x
Now install brew
Mountain Lion Fixes for Homebrew
Install X11: Visit and download and install version 2.7.2+.
and make a symlink
Reinstall your brews
Edit your profile
Paste the following into editor then Ctrl+X and Y to save
Set up email sending
First test if you are able to email yourself
If you are on Mountain Lion you need to create and set the permissions for these directories first (for DP4 at least)
Mountain Lion appears to have a few bugs around this at the moment, I have to launch postfix on reboot
Step 2: Setting up dnsmasq for local wildcard DNS
Install dnsmasq via homebrew
Copy and edit the default conf example
Update the following values as shown
Set up downstream DNS resolver
Paste the following and save using CTRL + X then Y
Copy the launch daemon so dnsmasq runs on startup, and launch it now
Setting up bind
BIND or named is the most widely used DNS software on the Internet, we will be configuring this for wildcard DNS of our development TLD (Top Level Domain) and using Google DNS as secondary DNS lookup for all other requests.
Open the terminal application and enter the following:
become root
Backup the default configuration
Create the keyfile that is read by both rndc and named on startup
Edit the named.conf file
Inside the “options {“ block add the following before the last }
Add the following just before zone "0.0.127.in-addr.arpa" IN {
Save your changes by hitting Ctrl+X then Y
Create db.ld file, we chose .ld for our TLD as it equated to local development in our minds
Paste the following
Save your changes by hitting Ctrl+X then Y
Run the following commands to ensure configuration is ok
For mavericks the resolvers are handled differently
Set your computers network settings to use 127.0.0.1 as DNS server in System Preferences -> Network for both Wireless and Ethernet connections by clicking Advanced and selecting the DNS tab
Set Bind to load on startup, and load it right now
Check setup with dig, were looking for NOERROR in the returned text
We can also test ping which should return something like the following (if not try a restart or dscacheutil -flushcache), hit Ctrl+C to cancel ping task
PING test.ld (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.033 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.061 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.060 ms
Set hostname as it's required for sane default in aegir setup, we chose rl.ld for Realityloop Local Development you can use something else instead of rl but it needs to end in .ld
Create configuration so that the wilcard is still accesible when you are not connected to a network
Paste the following and save using CTRL+X then Y to save:
Revert back to your default user instead of root
Set hostname as it's required for sane default in aegir setup, we chose locohost.ld for Local Development you can use something else instead of rl but it needs to end in .ld
Open your System Preferences, then click on Network, then for each of your interfaces (Wi-Fi & Ethernet), click on Advanced, click on DNS and finally click on the + symbol at the bottom of the left hand-side panel and set 127.0.0.1 as your only DNS Server
We can add some 3rd party extensions here as well (this list item is optional, if you don't want these extensions just skip to the next list item)
Now one giant line of sed regex that will edit the Homebrew formula for nginx to add the additional compile options that we need. Make sure it all gets entered as one line.
Now we'll install Nginx with our new build options and extensions and start it.
If you didn't use the above to install extra nginx extensions run this, otherwise skip this command
Once nginx is compiled, backup the default nginx config
Download our config as follows
Set your username in the downloaded config file
Make nginx log files visible in Console app
Create the following directorty to stop “"/var/lib/nginx/speed" failed (2: No such file or directory)” error
Once compilation has finished unset TMPDIR
Then mysql_install_db
Read the output but don't follow any more of the prompts just now or you will run into problems, we'll do the rest later.
You can start the MariaDB daemon with:
cd '.' ; ./bin/mysqld_safe --datadir='./data'
You can test the MariaDB daemon with mysql-test-run.pl
cd './mysql-test' ; perl mysql-test-run.pl
in mavericks you alseo need
now continue php-53
Edit the php.ini
Search for the extenstions section by using CTRL + W and typing: extension=php_zip.dll (check the installed versions match the text below, and update accordingly)
Set your timezone http://www.php.net/manual/en/timezones.php, I added the follwing under the ;date.timezone = line
And updated the Memory limit as follows, then saved with Ctrl+X then Y
Edit the php-fpm.conf file
Add the following line below ;pid = run/php-fpm.pid
Remove the ; from the start of the following lines then save using Ctrl+X then Y
Make our log file visible in Console app
Edit the plist
Remove the following 2 groups of text and save your changes using Ctrl+X then Y
Start nginx
Make a directory for the rest of our launch daemons
Copy the LaunchDaemon to load mariadb on boot into place and start it now
Copy php launch daemon and start it
Complete the mariaDB setup
Answer the prompts as follows, replace [password] with a password of your own chosing
Make a few small changes required for this to work properly
Allow your user to restart nginx, be sure to replace [username] with your own username.
Now we need to hookup php-fpm and nginx:
Paste and change to your needs:
Create a symbolic link to aegir configuration
Manually Install Drush and Aegir components
If you want to use drush 4.6 (we recommend Drush 5 though)
To install aegir with Drush 5 remember to replace client_email in the last command with your own email address
Remember to copy the one time login link and set your aegir admin password.
Remove the default platforms dir and create a symlink for so you can put your Platforms in ~/Sites/ directory
Disable the forced caching in aegir (this is for local dev after all!)
Paste the following text at the bottom of the document and save with CTRL +X then Y and return
Open your web browser and start creating platforms and sites!
http://aegir.ld
Sources:
RealityLoop and command-tab
Now edit nginx.conf
add the path to your conf.d
Now add a test.ld site
and paste
Now install brew
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
and make a symlink
sudo ln -s /opt/X11 /usr/X11
brew list
nano ~/.bash_profile
export PATH=~/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/usr/local/git/bin:/opt/local/bin
date | mail -s test you@youremail.com
sudo mkdir /Library/Server /Library/Server/Mail /Library/Server/Mail/Data /Library/Server/Mail/Data/spool /Library/Server/Mail/Data/spool/maildrop sudo chown _postfix:_postdrop /Library/Server/Mail/Data/spool/maildrop sudo chmod 777 /Library/Server/Mail/Data/spool/maildrop
sudo postfix start
brew install dnsmasq
mkdir /usr/local/etc cp $(brew --prefix dnsmasq)/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf nano /usr/local/etc/dnsmasq.conf
resolv-file=/etc/resolv.dnsmasq.conf address=/.ld/127.0.0.1 listen-address=127.0.0.1
sudo nano /etc/resolv.dnsmasq.conf
# OpenDNS IPv6: nameserver 2620:0:ccd::2 nameserver 2620:0:ccc::2 # Google IPv6: nameserver 2001:4860:4860::8888 nameserver 2001:4860:4860::8844 # OpenDNS: nameserver 208.67.222.222 nameserver 208.67.220.220 # Google: nameserver 8.8.8.8 nameserver 8.8.4.4
brew install bind sudo cp $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
sudo -i
cp /usr/local/etc/named.conf /usr/local/etc/named.conf.bck
rndc-confgen -a
nano /usr/local/etc/named.conf
forwarders { 8.8.8.8; //Google DNS 8.8.4.4; //Google DNS };
zone "ld" IN { type master; file "db.ld"; };
nano /var/named/db.ld
ld. 7200 IN SOA dev. root.ld. ( 2008031801 ; Serial 15 ; Refresh every 15 minutes 3600 ; Retry every hour 3000000 ; Expire after a month+ 86400 ) ; Minimum ttl of 1 day IN NS ld. IN MX 10 ld. IN A 127.0.0.1 *.ld. IN A 127.0.0.1
named-checkconf /etc/named.conf named-checkzone ld /var/named/db.ld
sudo mkdir -p /etc/resolver sudo nano /etc/resolver/ld #add nameserver 127.0.0.1
launchctl load -w /System/Library/LaunchDaemons/org.isc.named.plist
dig test.ld
ping test.ld
scutil --set HostName rl.ld
mkdir /etc/resolver nano /etc/resolver/ld
nameserver 127.0.0.1
exit
sudo scutil --set HostName loco.ld
Step 3: Install nginx
nginx (pronounced “engine-x”) is a Web server and a reverse proxy server for HTTP, SMTP, POP3 and IMAP protocols, with a strong focus on high concurrency, performance and low memory usage. Unless this is a fresh install of OS X you need to ensure Apache doesn't load on startupsudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
curl -s -L -o /tmp/nginx-upload-progress.tar.gz https://github.com/masterzen/nginx-upload-progress-module/tarball/v0.9.0 && mkdir /tmp/nginx-upload-progress && tar zxpf /tmp/nginx-upload-progress.tar.gz --strip-components 1 -C /tmp/nginx-upload-progress && rm /tmp/nginx-upload-progress.tar.gz curl -s -L -o /tmp/nginx-fair.tar.gz http://github.com/gnosek/nginx-upstream-fair/tarball/master && mkdir /tmp/nginx-fair && tar zxpf /tmp/nginx-fair.tar.gz --strip-components 1 -C /tmp/nginx-fair && rm /tmp/nginx-fair.tar.gz
sed -i '-default' 's/\([[:space:]]*\['\''--\)\(with-webdav\)\('\'',[[:space:]]*"\)\(Compile with support for WebDAV module\)\("\]\)/\1\2\3\4\5,%\1with-realip\3Compile with support for RealIP module\5,%\1with-gzip_static\3Compile with support for Gzip Static module\5,%\1with-uploadprogress\3Compile with support for Upload Progress module\5,%\1with-fair\3Compile with support for Fair module\5,%\1with-mp4\3Compile with support for MP4 module\5,%\1with-flv\3Compile with support for FLV module\5,%\1with-stub_status\3Compile with support for Stub Status module\5/; s/\([[:space:]]* args << "--\)\(with-http_dav_module\)\(" if ARGV.include? '\''--with-\)\(webdav\)\('\''.*\)/\1\2\3\4\5%\1with-http_realip_module\3realip\5%\1with-http_gzip_static_module\3gzip_static\5%\1add-module=\/tmp\/nginx-upload-progress\3uploadprogress\5%\1add-module=\/tmp\/nginx-fair\3fair\5%\1with-http_mp4_module\3mp4\5%\1with-http_flv_module\3flv\5%\1with-http_stub_status_module\3stub_status\5/; y/%/\n/' $(brew --prefix)/Library/Formula/nginx.rb
brew install nginx --with-realip --with-gzip_static --with-mp4 --with-flv --with-stub_status --with-uploadprogress --with-fair [ $? -eq 0 ] && rm -rf /tmp/nginx-upload-progress /tmp/nginx-fair mkdir -vp $(brew --prefix nginx)/var/{microcache,log,run}
brew install nginx
mv /usr/local/etc/nginx/nginx.conf /usr/local/etc/nginx/nginx.conf.bak
curl http://realityloop.com/sites/realityloop.com/files/uploads/nginx.conf_.txt > /usr/local/etc/nginx/nginx.conf
sed -i -e 's/\[username\]/'`whoami`'/' /usr/local/etc/nginx/nginx.conf
sudo mkdir /var/log/nginx
sudo mkdir /var/lib/nginx
Step 4: MariaDB
MariaDB is a community-developed branch of the MySQL database, the impetus being the community maintenance of its free status under GPL, as opposed to any uncertainty of MySQL license status under its current ownership by Oracle. The intent also being to maintain high fidelity with MySQL, ensuring a "drop-in" replacement capability with library binary equivalency and exacting matching with MySQL APIs and commands. It includes the XtraDB storage engine as a replacement for InnoDB. Still in the ‘Terminal app’, type the following commandbrew install mariadb --use-llvm --env=std
unset TMPDIR
cd /usr/local/Cellar/mariadb/5.5.28/ mysql_install_db
cd '.' ; ./bin/mysqld_safe --datadir='./data'
You can test the MariaDB daemon with mysql-test-run.pl
cd './mysql-test' ; perl mysql-test-run.pl
Step 5: Install the homebrew version of php
Execute the brew install process using hombrew-alt php brew filebrew tap josegonzalez/homebrew-php brew tap homebrew/dupes
brew tap homebrew/versions
brew install php53 --with-mysql --with-fpm --with-imap brew install php53-xhprof brew install php53-xdebug brew install php53-uploadprogress
nano /usr/local/etc/php/5.3/php.ini
extension="/usr/local/Cellar/php53-xhprof/0.9.2/xhprof.so" extension="/usr/local/Cellar/php53-uploadprogress/1.0.3.1/uploadprogress.so" zend_extension="/usr/local/Cellar/php53-xdebug/2.2.1/xdebug.so"
date.timezone = Europe/Amsterdam
memory_limit = 256M
nano /usr/local/etc/php/5.3/php-fpm.conf
pid = /usr/local/var/run/php-fpm.pid
pm.start_servers = 3 pm.min_spare_servers = 3 pm.max_spare_servers = 5 pm.max_requests = 500
sudo ln -s $(brew --prefix josegonzalez/php/php53)/var/log/php-fpm.log /var/log/nginx/php-fpm.log
Step 6: Service Launch Daemons
This is so everything runs automatically on startup Nginx needs to run as root for port 80 so do the followingsudo cp $(brew --prefix nginx)/homebrew.mxcl.nginx.plist /Library/LaunchDaemons/ sudo chown root:wheel /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
sudo nano /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
<key>KeepAlive</key> <true/> <key>UserName</key> <string>yourusername</string>
launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
mkdir -p ~/Library/LaunchAgents
cp $(brew --prefix mariadb)/homebrew.mxcl.mariadb.plist ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
cp $(brew --prefix josegonzalez/php/php53)/homebrew-php.josegonzalez.php53.plist ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php53.plist
sudo $(brew --prefix mariadb)/bin/mysql_secure_installation
Enter current password for root (enter for none): [Enter] Set root password? [Y/n] y New password: [password] Re-enter new password: [password] Remove anonymous users? [Y/n] y Disallow root login remotely? [Y/n] y Remove test database and access to it? [Y/n] y Reload privilege tables now? [Y/n] y
Step 7: Drush and Aegir
Your in the home stretch now! Install wget so Drush will work properly (need to do this on Mountain Lion)brew install wget
sudo mkdir /var/aegir sudo chown `whoami` /var/aegir sudo chgrp staff /var/aegir sudo dscl . append /Groups/_www GroupMembership `whoami`
sudo -i echo "[username] ALL=NOPASSWD: /usr/local/sbin/nginx" >> /etc/sudoers exit
nano /usr/local/etc/nginx/php.conf
fastcgi_intercept_errors on; location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; fastcgi_read_timeout 600; # Set fairly high for debugging fastcgi_pass 127.0.0.1:9000; # Non-default port fastcgi_index index.php; }
sudo ln -s /var/aegir/config/nginx.conf /usr/local/etc/nginx/aegir.conf
brew tap BrianGilbert/homebrew-drush
To install aegir with Drush 4 remember to replace client_email in the last command with your own email address
brew install drush46 drush dl --destination=/users/`whoami`/.drush drush_make-6.x drush dl --destination=/users/`whoami`/.drush provision-6.x drush hostmaster-install --aegir_root='/var/aegir' --root='/var/aegir/hostmaster-6.x-1.9' --http_service_type=nginx --client_email=email@domain.com
brew install drush drush dl --destination=/users/`whoami`/.drush provision-6.x-2.x drush hostmaster-install --aegir_root='/var/aegir' --root='/var/aegir/hostmaster-6.x-2.x-dev' --http_service_type=nginx --aegir_host=aegir.ld --client_email=email@domain.com
mkdir /Users/`whoami`/Sites rmdir /var/aegir/platforms ln -s /Users/`whoami`/Sites /var/aegir/platforms
nano /var/aegir/config/includes/global.inc
header('X-Accel-Expires: 0'); //disable nginx caching unset($conf['cache']); // disable hardcoded caching unset($conf['preprocess_css']); // disable hardcoded css aggregation unset($conf['preprocess_js']); // disable hardcoded js aggregation
Sources:
RealityLoop and command-tab
Configure local development
mkdir /Users/%user/www/ mkdir /Users/%user/www/sites mkdir /Users/%user/www/conf.d> mkdir /Users/%user/www/log
nano /usr/local/etc/nginx/nginx,conf
include /Users/%user/www/conf.d/*.vhost
nano /Users/%user/www/conf.d/test.vhost
GNU nano 2.2.6 File: test.vhost server { listen 80; server_name test.ld; root /Users/%user/www/sites/test; access_log /Users/%user/www/log/access.log; error_log /Users/%user/www/log/error.log; location / { index index.php; try_files $uri $uri/ /index.php?q=$uri&$args; } include /usr/local/etc/nginx/php.conf; }